移动设备横竖屏监听事件

window.addEventListener('orientationchange', function(event){
    if ( window.orientation == 180 || window.orientation==0 ) {
         alert("竖屏");    //竖屏事件处理
    }
    if( window.orientation == 90 || window.orientation == -90 ) {
         alert("横屏");    //横屏事件处理
    }
});

posted @ 2016-08-19 17:24  CodeProducter  阅读(1042)  评论(0编辑  收藏  举报