admin管理员组

文章数量:1564204

 

    /* js判断手机浏览器屏幕方向*/
    var direction = {
        __getOrientation: function () {
            if (window.orientation == 0 || window.orientation == 180) {/* alert("竖屏状态!")*/
                return true;
            }
            if (window.orientation == 90 || window.orientation == -90) {/* alert("横屏状态!")*/
                return false;
            }
        }, __doOrientation: function () {
            document.querySelector("html").className = direction.__getOrientation() ? "orientation" : "";
        }, init: function () { /*旋转手机屏幕触发下面的事件*/
            window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", this.__doOrientation, false);
            this.__doOrientation();
        }
    };
    direction.init();

本文标签: 屏幕浏览器方向手机js