js判断手机 横屏模式

js判断手机 横屏模式

方法名称:orientation


实例:

if(window.orientation!=0){
        var obj=document.getElementById('orientation');
        alert('横屏内容太少啦,请使用竖屏观看!');
        obj.style.display='block';
}

window.onorientationchange=function(){
var obj=document.getElementById('orientation');

if(window.orientation==0){
                obj.style.display='none';
        }else
        {
                alert('横屏内容太少啦,请使用竖屏观看!');
                obj.style.display='block';
        }
};

 

posted @ 2016-07-13 14:18  北执  阅读(1643)  评论(0编辑  收藏  举报