js获取浏览器内核和版本
1 <script type="text/javascript"> 2 function Navigator(){ 3 var Sys = {}, 4 ua = navigator.userAgent.toLowerCase(), 5 s; 6 7 (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : 8 9 (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : 10 11 (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] : 12 13 (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] : 14 15 (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0; 16 17 //以下进行测试 18 var appName,appVersion; 19 20 if(Sys.ie){ 21 appName ="IE"; 22 appVersion= Sys.ie; 23 } 24 25 if(Sys.firefox){ 26 appName ="Firefox"; 27 appVersion= Sys.firefox; 28 } 29 30 if(Sys.chrome){ 31 appName ="Chrome"; 32 appVersion= Sys.chrome; 33 } 34 35 if(Sys.opera){ 36 appName ="Opera"; 37 appVersion= Sys.opera; 38 } 39 40 if(Sys.safari){ 41 appName ="Safari"; 42 appVersion= Sys.safari; 43 } 44 45 //console.log ({"appName":appName ,"appVersion":appVersion}) 46 return {"appName":appName ,"appVersion":appVersion} 47 48 } 49 50 Navigator() 51 </script>