js没这么高的权限要求系统这么做,一般是检测判断高小于宽的时候提示用户就行了(用户体验比较好)
<!-- android强制竖屏 ios暂时无效 -->
<meta name="msapplication-tap-highlight" content="no">
<!-- uc浏览器强制竖屏 -->
<meta name="screen-orientation" content="portrait">
<!-- QQ浏览器强制竖屏 -->
<meta name="x5-orientation" content="portrait">
方式二,横屏时提示用户请竖屏(提高用户体验度)
html
<!--旋转提示--> <!-- 选择禁止横屏或竖屏显示-->
<div id="orientLayer" class="mod-orient-layer">
<div class="mod-orient-layer__content">
<i class="icon mod-orient-layer__icon-orient" />
<div class="mod-orient-layer__desc">为了更好的体验,请使用竖屏浏览</div>