JQuery判断浏览器类型

浏览器内核标识,依据 navigator.userAgent 判断。
mozilla 此属性在 DOM 树加载完成前即有效,可用于为特定浏览器设置 ready 事件。 

参考文档:http://api.jquery.com/jQuery.browser/

待验证代码:

 1 <SCRIPT language="JavaScript">
 2 function myexplorer(){
 3 var explorer = window.navigator.userAgent;
 4 if (explorer.indexOf("QQBrowser")>=0 || explorer.indexOf("QQ")>=0){return myexplorer="腾讯QQ";
 5 }else if(explorer.indexOf("Safari")>=0 && explorer.indexOf("MetaSr")>=0){return myexplorer="搜狗";
 6 }else if (!!window.ActiveXObject || "ActiveXObject" in window){//IE
 7     if (!window.XMLHttpRequest){return myexplorer="IE6";
 8     }else if (window.XMLHttpRequest && !document.documentMode){return myexplorer="IE7";
 9     }else if (!-[1,] && document.documentMode && !("msDoNotTrack" in window.navigator)){return myexplorer="IE8";
10     }else{//IE9 10 11
11     var hasStrictMode=(function(){"use strict";return this===undefined;}()); 
12     if (hasStrictMode){
13         if (!!window.attachEvent){return myexplorer="IE10";}else{return myexplorer="IE11";}
14     }else{
15         return myexplorer="IE9";
16     }
17     }
18 }else{//非IE
19     if (explorer.indexOf("LBBROWSER") >= 0){return myexplorer="猎豹";
20     }else if(explorer.indexOf("360ee")>=0){return myexplorer="360极速浏览器";
21     }else if(explorer.indexOf("360se")>=0){return myexplorer="360安全浏览器";
22     }else if(explorer.indexOf("se")>=0){return myexplorer="搜狗浏览器";
23     }else if(explorer.indexOf("aoyou")>=0){return myexplorer="遨游浏览器";
24     }else if(explorer.indexOf("qqbrowser")>=0){return myexplorer="QQ浏览器";
25     }else if(explorer.indexOf("baidu")>=0){return myexplorer="百度浏览器";
26     }else if(explorer.indexOf("Firefox")>=0){return myexplorer="火狐";
27     }else if(explorer.indexOf("Maxthon")>=0){return myexplorer="遨游";
28     }else if(explorer.indexOf("Chrome")>=0){return myexplorer="谷歌(或360伪装)";
29     }else if(explorer.indexOf("Opera")>=0){return myexplorer="欧朋";
30     }else if (explorer.indexOf("TheWorld") >= 0){return myexplorer="世界之窗";
31     }else if(explorer.indexOf("Safari")>=0){return myexplorer="苹果";
32 
33     }else{return myexplorer="其他";
34     }
35 }
36 }</script>
37 <BR>
38 <SCRIPT>document.write("客户端浏览器是:"+myexplorer());</script>

 

JQuery判断浏览器类型,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。