/判斷手機橫豎屏狀態:
function hengshuping(){
if(window.orientation==180||window.orientation==0){
alert("豎屏狀態!")
}
if(window.orientation==90||window.orientation==-90){
alert("橫屏狀態!")
}
}
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", hengshuping, false);
//移動端的瀏覽器一般都支持window.orientation這個參數,通過這個參數可以判斷出手機是處在橫屏還是豎屏狀態。
從而根據實際需求而執行相應的程序。通過添加監聽事件onorientationchange,進行執行就可以了。
http://blog.csdn.net/lee_magnum/article/details/17429613
