It is often necessary to distinguish between different browsers, so here are a few methods to differentiate various versions of IE. First, to identify an IE browser, we primarily use the ActiveXObject, which is a unique object of IE, to determine if it is an IE browser. Based on this, we can use XMLHttpRequest to check for IE6, and documentMode to identify IE8. As for IE7, there is no specific method provided; of course, considering that IE10 has already been released, the issues to consider are not so simple. I will update on distinguishing IE10 after I get to test it.
var isIE=!!window.ActiveXObject;
var isIE6=isIE&&!window.XMLHttpRequest;
var isIE8=isIE&&!!document.documentMode;
var isIE7=isIE&&!isIE6&&!isIE8;
if (isIE){
if (isIE6){
alert(”ie6″);
}else if (isIE8){
alert(”ie8″);
}else if (isIE7){
alert(”ie7″);
}
}