JS侦测设备旋转方向

window.onload = window.onresize = function initialLoad(){updateOrientation();}
function updateOrientation(){
    var contentType = '';
    switch(window.orientation){
        case 0:
            contentType = 'normal';
            break;
        case -90:
            contentType = 'left';
            break;
        case 90:
            contentType = 'right';
            break;
        case 180:
            contentType = 'flipped';
            break;
    };
    alert(contentType);
}

  

posted @ 2014-11-05 10:40  Joerias  阅读(328)  评论(0编辑  收藏  举报