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';
        }
}; 

原文地址:https://www.cnblogs.com/Gbeniot/p/4096535.html