通过js较精确识别不同浏览器

来源:互联网 发布:通讯软件有哪些 编辑:程序博客网 时间:2024/04/27 18:05
function onloade() {
  if(window.ActiveXObject){
   //判断是否是IE 7 以上
    if(document.documentElement && typeof document.documentElement.style.maxHeight!="undefined" ){
      //判断是否是IE8
       if(typeof document.adoptNode!="undefined"){
        //return "IE 8"
        alert("IE 8");
        }
        //return "IE 7";
        alert("IE 7");
     }
     //opera独占
  }else if (typeof window.opera!="undefined"){
   //return "opera";
   alert("opera");
   }
   //Mozilla独占
   else if(typeof window.netscape !="undefined"){
     if(typeof window.Iterator !="undefined"){
       if(typeof document.styleSheetSet !="undefined"){
        //firefox 3
        //return "firfox 3";
        alert("firfox 3");
        }
      }
      //return "mozilla";
    } 
    else if(typeof window.pageXOffset !="undefined"){
     try {
     if(typeof external.AddSearchProvider !="undefined"){
      //return "chome";
      alert("chome");
     }
    } catch (e) {
     // TODO: handle exception
     //return "safari"
     alert("safari");
    }
    }else {
     //return "unknown";
     alert("unknown");
    }
 }
0 0
原创粉丝点击