js 判断ie的版本号

//IE6判断:  
var isIE6 = !!window.ActiveXObject && !window.XMLHttpRequest;  
//或者:  
if(navigator.userAgent.indexOf("MSIE 6.0")>0){  
    alert("ie6");  
}  
//IE7判断:  
if(navigator.userAgent.indexOf("MSIE 7.0")>0){  
    alert("ie7");  
}  
  
//IE8判断:  
if(!!window.ActiveXObject && document.documentMode==8){  
    alert("ie8");  
}  
  
//IE9判断:  
if(!!window.ActiveXObject && document.documentMode==9){  
    alert("ie8");  
}  
  
//IE10判断:  
if(!!window.ActiveXObject && document.documentMode==10){  
    alert("ie8");  
}

  

猜你喜欢

转载自www.cnblogs.com/ryanzheng/p/9039926.html