JS获取浏览器信息
function getExplore(){
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/rv:([\d.]+)\) like gecko/)) ? Sys.ie = s[1] :
(s = ua.match(/msie ([\d\.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/edge\/([\d\.]+)/)) ? Sys.edge = s[1] :
(s = ua.match(/firefox\/([\d\.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/(?:opera|opr).([\d\.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/chrome\/([\d\.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/version\/([\d\.]+).*safari/)) ? Sys.safari = s[1] : 0;
// 根据关系进行判断
if (Sys.ie) return ('IE: ' + Sys.ie);
if (Sys.edge) return ('EDGE: ' + Sys.edge);
if (Sys.firefox) return ('Firefox: ' + Sys.firefox);
if (Sys.chrome) return ('Chrome: ' + Sys.chrome);
if (Sys.opera) return ('Opera: ' + Sys.opera);
if (Sys.safari) return ('Safari: ' + Sys.safari);
return 'Unkonwn';
}
function getExploreName(){
var userAgent = navigator.userAgent;
if(userAgent.indexOf("Opera") > -1 || userAgent.indexOf("OPR") > -1){
return 'Opera';
}
else if(userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1){
return 'IE';
}
else if(userAgent.indexOf("Edge") > -1){
return 'Edge';
}
else if(userAgent.indexOf("Firefox") > -1){
return 'Firefox';
}
else if(userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1){
return 'Safari';
}
else if(userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1){
return 'Chrome';
}
else if(!!window.ActiveXObject || "ActiveXObject" in window){
return 'IE>=11';
}
else{
return 'Unkonwn';
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
上次更新: 2024/01/30, 00:35:17
- 02
- Node与GLIBC_2.27不兼容解决方案08-19
- 03
- Git清空本地文件跟踪缓存08-13