您的位置:首页 > Web前端 > JavaScript

JS判断设备 检查手机系统 检测系统

2017-09-29 00:00 393 查看
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
if(window.location.href.indexOf("?mobile")<0){
try{
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
window.location.href="../m/index.html";
}else if(/iPad/i.test(navigator.userAgent)){
//ipad
}else{
// 其他
}
}catch(e){}
}
}

function getPgjs(){
var agent = navigator.userAgent.toLowerCase();
var res = agent.match(/android/);
if(res == "android")
return res;
res = agent.match(/iphone/);
if(res == "iphone")
return "ios";
res = agent.match(/ipad/);
if(res == "ipad")
return "ios";
res = agent.match(/windows/);
if(res == "windows")
return "wp";
return "pc";
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: