javaScript 判断横竖屏

  

window.addEventListener("onorientationchange" in window ? orientationchange" : "resize",transformScreen , false);
function transformScreen() {
  if (window.orientation === 180 || window.orientation === 0) { 
       alert('竖屏状态!');
  } 
  if (window.orientation === 90 || window.orientation === -90 ){ 
       alert('横屏状态!');
  }   
}

 

posted @ 2019-07-18 19:04  mumengchun  阅读(357)  评论(0编辑  收藏  举报