zoukankan      html  css  js  c++  java
  • 用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("平板");
        }
    

      

  • 相关阅读:
    创建进程
    进程
    操作系统历史
    socket
    网络基础
    常用模块二:hashlib、configparser、logging
    常见正则匹配
    类中的内置方法(魔法方法、双下方法)
    反射、isinstance和issubclass
    封装、继承、多态
  • 原文地址:https://www.cnblogs.com/summerXll/p/9008632.html
Copyright © 2011-2022 走看看