js判断苹果xx还是安卓

原创 小棋子 随笔 js 108阅读 2019-04-11 10:28:19 举报

console.log(navigator.userAgent);
console.log(navigator.appVersion);
console.log(navigator)
if(events.indexOf('Android')>-1 || events.indexOf('Linux')>-1 || events.indexOf('Adr')>-1){
console.log("安卓手机");
}else if(events.indexOf('iPhone')>-1){
//根据尺寸进行判断 苹果的型号
if(screen.height == 812 && screen.width == 375){
console.log("苹果X");
}else if(screen.height == 736 && screen.width == 414){
console.log("iPhone7P - iPhone8P - iPhone6");
}else if(screen.height == 667 && screen.width == 375){
console.log("iPhone7 - iPhone8 - iPhone6");
}else if(screen.height == 568 && screen.width == 320){
console.log("iPhone5");
}else{
console.log("iPhone4");
}
}else if(events.indexOf('Windows Phone')>-1){
console.log("诺基亚手机");

}else if(events.indexOf("iPad")>-1){
    console.log("平板");
}
评论 ( 0 )
最新评论
暂无评论

赶紧努力消灭 0 回复