window.orientation 对象在手机上才可生效。
<script type="text/javascript">
var evt = "onorientationchange" in window ? "orientationchange" : "resize";
window.addEventListener(evt,resize,false);
function resize(fals) {
if(window.orientation == 0 || window.orientation == 180) {
alert("竖屏");
}else {
alert("横屏");
}
}
resize(true);
</script>
网友评论