js判断是否是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
        } 
    }
}

引用地址