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);

}

  

你可能感兴趣的:(js)