[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();}