js判断手机 横屏模式

时间:2021-04-12 15:08:37

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