window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() {
if (window.orientation === 180 || window.orientation === 0) {
alert('竖屏状态!');
//做相对应的处理
}
if (window.orientation === 90 || window.orientation === -90 ){
alert('横屏状态!');
//做相对应的处理
}
}, false);