1. 程式人生 > >js移動端頁面判斷是否是iphoneX

js移動端頁面判斷是否是iphoneX

判斷iphoneX

function isIPhoneX(fn){
    var u = navigator.userAgent;
    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios終端
    if (isIOS) {        
        if (screen.height == 812 && screen.width == 375){
            //是iphoneX
        }else{
            //不是iphoneX
        } 
    }
}