
帐号登录 邮箱快速注册
判断手机设备是ios系统,还是安卓(android)系统,或者是iphone。
function getMobileSystem() {
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android系统
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios系统
var iphoneX = /iphone/gi.test(navigator.userAgent) && (screen.height == 812 && screen.width == 375)
// 返回1是android系统
if (isAndroid) {
return 1;
}
// 返回2是ios系统
if (isiOS && !iphoneX) {
return 2;
}
// 返回3是iphoneX
if (iphoneX) {
return 3;
}
return 0;
}
getMobileSystem() 返回“1”是安卓手机;返回“2||3”是ios系统;返回“3”是iphoneX;返回“0”是其他系统。