【JS】手机屏幕旋转判断

function readDeviceOrientation() {
                         
        if (Math.abs(window.orientation) === 90) {
            // Landscape
            alert('横屏');
        } else {
            // Portrait
            alert('竖屏');
        }
    }

    window.onorientationchange = readDeviceOrientation;

 

posted @ 2015-09-25 08:01  Younger  阅读(934)  评论(0编辑  收藏  举报