当前位置: 代码迷 >> JavaScript >> JS 判断手机横屏仍是直屏
  详细解决方案

JS 判断手机横屏仍是直屏

热度:419   发布时间:2013-04-02 12:35:26.0
JS 判断手机横屏还是直屏
查了不少资料,最后结论如下: 
复制代码 代码如下: 
function orientationChange(){ 
switch(window.orientation) { 
case 0: // Portrait 
case 180: // Upside-down Portrait 
// Javascript to setup Portrait view 
break; 
case -90: // Landscape: turned 90 degrees counter-clockwise 
case 90: // Landscape: turned 90 degrees clockwise 
// Javascript to steup Landscape view 
break; 
} 
} 
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", orientationChange, false); 

?

  相关解决方案