html页面禁止竖屏,关于移动端页面强制竖屏的方法

最近工作中写了一个移动端的页面,本来是没什么的,但是有一个要求感觉很奇怪,从前也没有遇到过,就是我写的这个页面需要放在一个APP中,但是这个APP是横屏的,打开这个页面的webview也是横屏的(最新版的APP打开的时候是竖屏的webview),本来我们是用的rem布局,横屏的状态下也是没有什么问题的,但是甲方希望在横屏打开的时候强制这个页面竖屏显示。所以就有了下面一系列的操作了。

首先是判断横屏的状态,使用的一下的代码:

function orient() {

if(window.orientation == 90 || window.orientation == -90) {//横屏

//ipad、iphone竖屏;Andriod横屏

//$("body").attr("class", "landscape");

//orientation = 'landscape';

//alert("ipad、iphone竖屏;Andriod横屏");

$("p").text("横屏");

return false;

} else if(window.orientation == 0 || window.orientation == 180) {//竖屏

//ipad、iphone横屏;Andriod竖屏

// $("body").attr("class", "portrait");

// orientation = 'po

你可能感兴趣的:(html页面禁止竖屏)