[JS代码]如何判断ipad或者iphone是否为横屏或者竖屏 - portrait或者landscape

      //判断横屏或者竖屏
function orient() {
//alert('gete');
if (window.orientation == 0 || window.orientation == 180) {
document.getElementById("os").innerHTML += "portrait";
//$("body").attr("class", "portrait");
orientation = 'portrait';
return false;
}
else if (window.orientation == 90 || window.orientation == -90) {
document.getElementById("os").innerHTML += "landscape";
// $("body").attr("class", "landscape");
orientation = 'landscape'; return false;
}
}

window.onresize = function (){orient();}

上一篇:Windows Store App 旋转特效


下一篇:HDU 2852 KiKi's K-Number(树状数组+二分搜索)