Javascript 判断手机横竖屏状态

判断手机横竖屏状态:

<script type=”text/javascript”>
function hengshuping(){
if(window.orientation==180||window.orientation==0){
alert(“竖屏状态!”)
}
if(window.orientation==90||window.orientation==-90){
alert(“横屏状态!”)
}
}
window.addEventListener(“onorientationchange” in window ? “orientationchange” : “resize”, hengshuping, false);
</script>

 

posted @ 2015-08-31 11:07  ElvinLong  阅读(237)  评论(0编辑  收藏  举报