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 {
            //豎屏
        }
    }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM