js 移动端网页 判断横屏和竖屏

window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function () {
    if (window.orientation === 180 || window.orientation === 0) {
        //竖屏
    }
    if (window.orientation === 90 || window.orientation === -90) {
        //横屏
    }
}, false);

你可能感兴趣的:(js 移动端网页 判断横屏和竖屏)