码迷,mamicode.com
首页 > 移动开发 > 详细

javascript判断手机旋转横屏竖屏

时间:2015-01-05 18:01:36      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

javascript判断手机旋转横屏竖屏

 

 

// 横屏竖屏函数
function orientationChange(){
    switch(window.orientation) {
        case 0: // Portrait
        case 180: // Upside-down Portrait
        //Javascript to setup Portrait view
        window.location.reload();       
        break;
        case -90: // Landscape: turned 90 degrees counter-clockwise
        case 90: // Landscape: turned 90 degrees clockwise
        //Javascript to steup Landscape view
        window.location.reload();       
        break;
    }
}
 window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", orientationChange, false); // 横屏竖屏时间

 

javascript判断手机旋转横屏竖屏

标签:

原文地址:http://www.cnblogs.com/xiaoqian1993/p/4204016.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!