js 브라우저 커널과 버전 가져오기

13823 단어 브라우저
 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>

좋은 웹페이지 즐겨찾기