html5横、竖屏状态 以及禁止横屏

原文:https://blog.csdn.net/wangshu696/article/details/43196349

<meta name="screen-orientation" content="portrait"><!-- uc强制竖屏 -->

<meta name="x5-orientation" content="portrait"><!-- QQ强制竖屏 -->

代码:

window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", hengshuping, false);


 function hengshuping() {
        if (window.orientation == 90 || window.orientation == -90) {
           //横屏
        } else {
            //竖屏
        }
    }

猜你喜欢

转载自www.cnblogs.com/apgy/p/10973515.html