jquery 判断是否 ie6 ie7 ie8

  1. var isIE = !!window.ActiveXObject;  
  2. var isIE6 = isIE && !window.XMLHttpRequest;  
  3. var isIE8 = isIE && !!document.documentMode;  
  4. var isIE7 = isIE && !isIE6 && !isIE8; 

 

 

 


var isIE = navigator.userAgent.indexOf('MSIE') != -1;
var isIE6 = navigator.userAgent.indexOf('MSIE 6.0') != -1;
var isIE8 = !!window.XDomainRequest && !!document.documentMode;

 

 

 

 

 

 

 

 

<script language="javascript">
    if(window.XMLHttpRequest)//判断浏览器是否属于Mozilla,Sofari
    {
        alert("firefox");
    }
    else if(window.ActiveXObject)//判断浏览器是否属于IE
    {
        var browser=navigator.appName 
        var b_version=navigator.appVersion 
        var version=b_version.split(";"); 
        var trim_Version=version[1].replace(/[ ]/g,""); 
        if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
        { 
        alert("IE 7.0"); 
        } 
        else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
        { 
        alert("IE 6.0"); 
        } 
    }

posted @ 2013-06-16 14:24  AYUI框架  阅读(947)  评论(2编辑  收藏  举报