js判断iPhoneX

1
2
3
4
5
6
7
8
9
10
if (navigator.userAgent.match(/(iPhone)/)) {
if ((screen.availHeight == 812) && (screen.availWidth == 375)) {
// iPhone X Landscape 横屏
if ((window.innerHeight == "375") && (window.innerWidth == "812")) {

} else {// iPhone X Portrait 竖屏

}
}
}