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