-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient.navigator.useragent.js
61 lines (60 loc) · 1.82 KB
/
client.navigator.useragent.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* JS通过navigator.userAgent判定设备信息
*/
var client_info = navigator.userAgent.toLowerCase();
var ClientUserAgent = {
/*判断移动设备类型*/
isMobile: function () {
return !!client_info.match(/ipad|iphone|android|blackberry|windows phone|webos/i);
},
isiOS: function () {
return !!client_info.match(/iphone|ipad|ipod/i);
},
isiPhone: function () {
return !!client_info.match(/iphone/i);
},
isiPad: function () {
return !!client_info.match(/ipad/i);
},
isiPod: function () {
return !!client_info.match(/ipod/i);
},
isAndroid: function () {
return !!client_info.match(/android/i);
},
isBlackBerry: function () {
return !!client_info.match(/blackberry/i);
},
isOpera: function () {
return !!client_info.match(/opera mini/i);
},
isWPhone: function () {
return !!client_info.match(/iemobile/i);
},
/*判断浏览器类型*/
isFirefox: function () {
return !!(client_info.indexOf('firefox') > -1);
},
isChrome: function () {
return !!(client_info.indexOf('chrome') > -1);
},
isIE11: function () {
return !!(client_info.indexOf('trident') > -1 && client_info.indexOf('rv:11') > -1);
},
isIE10_X: function () {
return !!(client_info.indexOf('msie') > -1);
},
isIE: function () {
return !!(client_info.indexOf('trident') > -1 && client_info.indexOf('rv:11') > -1) || !!(client_info.indexOf('msie') > -1);
},
isOpera: function () {
return !!(client_info.indexOf('opera') > -1);
},
isChrome: function () {
return !!(client_info.indexOf('chrome') > -1);
},
/*判断是否为微信浏览器*/
isWeChat: function () {
return !!client_info.match(/micromessenger/i);
}
};