H5判断设备系统
H5 判断设备系统
H5 判断设备系统
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
u = navigator.userAgent;
const syetem = {
trident: u.indexOf("Trident") > -1,
presto: u.indexOf("Presto") > -1,
webKit: u.indexOf("AppleWebKit") > -1,
gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") == -1,
mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/),
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1,
iPhone: u.indexOf("iPhone") > -1 || u.indexOf("Mac") > -1,
iPad: u.indexOf("iPad") > -1,
webApp: u.indexOf("Safari") == -1,
weixin: u.match(/micromessenger/i),
appVersion: appV,
xyapp: u.indexOf("XinhuasheBrower") > -1,
qq: u.indexOf("QQ/") > -1,
qqBrowser: u.indexOf("MQQBrowser") > -1,
wechat: u.indexOf("MicroMessenger/") > -1,
isDin: u.indexOf("DingTalk") > -1,
weibo: u.match(/WeiBo/i),
};
if (syetem.ios || syetem.iphone || syetem.iPad) {
// 苹果
} else {
// 安卓
}
本文由作者按照 CC BY 4.0 进行授权