用js判断 iPhone6 iPhone6 plus iphonex?


 

var events = navigator.userAgent;
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){
// 进行操作,改变样式

const obj = document.getElementById('sendxBtn')
obj.setAttribute("style", "padding:5px 10px 20px;")

            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("平板");
    }

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM