如果想测试某个浏览器的特征可以通过如下方法获取
JS获取浏览器信息
浏览器代码名称:navigator.appCodeName
浏览器名称:navigator.appName
浏览器版本号:navigator.appVersion
对Java的支持:navigator.javaEnabled()
MIME类型(数组):navigator.mimeTypes
系统平台:navigator.platform
插件(数组):navigator.plugins
用户代理:navigator.userAgent
比较全的
1 <script type="text/javascript"> ?2 document.write(‘浏览器判別:‘); 3 var OsObject=navigator.userAgent; 4 // 包含「Opera」文字列 ?5 if(OsObject.indexOf("Opera") != -1) ?6 { ?7 ???document.write(‘您的浏览器是Opera吧?‘); ?8 } ?9 // 包含「MSIE」文字列 10 else if(OsObject.indexOf("MSIE") != -1) 11 { 12 ???document.write(‘您的浏览器是Internet Explorer吧?‘); 13 } 14 // 包含「chrome」文字列 ,不过360浏览器也照抄chrome的UA15 ?16 else if(OsObject.indexOf("Chrome") != -1) 17 { 18 ??document.write(‘您的浏览器是chrome或360浏览器吧?‘); 19 }20 // 包含「UCBrowser」文字列 21 else if(OsObject.indexOf("UBrowser") != -1) 22 { 23 ??document.write(‘您的浏览器是UBrowser吧?‘); 24 }25 // 包含「BIDUBrowser」文字列 26 else if(OsObject.indexOf("BIDUBrowser") != -1) 27 { 28 ??document.write(‘您的浏览器是百度浏览器吧?‘); 29 }30 // 包含「Firefox」文字列 31 else if(OsObject.indexOf("Firefox") != -1) 32 { 33 ??document.write(‘您的浏览器是Firefox吧?‘); 34 }35 // 包含「Netscape」文字列 36 else if(OsObject.indexOf("Netscape") != -1)37 { 38 ??document.write(‘您的浏览器是Netscape吧?‘); 39 } 40 // 包含「Safari」文字列 41 else if(OsObject.indexOf("Safari") != -1) 42 { 43 ???document.write(‘您的浏览器是Safari 吧?‘); 44 } 45 else{ 46 document.write(‘无法识别的浏览器。‘); 47 } 48 </script>
如何利用js识别不同的浏览器
原文地址:http://www.cnblogs.com/i-want-to-be-like-an-sun/p/7573664.html