用JavaScript判斷橫屏豎屏問題。JavaScript代碼以下【轉】

/判斷手機橫豎屏狀態:   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瀏覽器

相關文章
相關標籤/搜索