js判断手机 横屏模式

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 @ 2014-11-14 09:56  G-Beniot  阅读(599)  评论(0编辑  收藏  举报