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>
时间: 2024-07-29 19:06:02

Javascript 判断手机横竖屏状态的相关文章

判断手机横竖屏

//判断手机横竖屏状态:window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() { if (window.orientation === 180 || window.orientation === 0) { //竖屏 } if (window.orientation === 90 || window.o

zepto判断手机横竖屏

var CheckOrientation = (function(){ var win = $( window ), get_orientation, last_orientation, initial_orientation_is_landscape, initial_orientation_is_default, portrait_map = { "0": true, "180": true }, ww, wh, landscape_threshold; if(

CSS3(@media)判断手机横竖屏

@media all and (orientation : landscape) { h2{color:red;}/*横屏时字体红色*/ } @media all and (orientation : portrait){ h2{color:green;}/*竖屏时字体绿色*/ } 原文地址:https://www.cnblogs.com/1032473245jing/p/8945096.html

使用JavaScript判断手机处于横屏还是竖屏

移动端的浏览器一般都支持window.orientation这个参数,通过这个参数可以判断出手机是处在横屏还是竖屏状态.从而根据实际需求而执行相应的程序.通过添加监听事件onorientationchange,进行执行就可以了. //判断手机横竖屏状态: function hengshuping(){ if(window.orientation==180||window.orientation==0){ alert("竖屏状态!") } if(window.orientation==9

用JavaScript判断横屏竖屏问题

判断手机横竖屏状态: 1 //判断手机横竖屏状态: 2 3 function hengshuping() { 4 if(window.orientation == 180 || window.orientation==0){ 5 alert("竖屏状态!");} 6 } 7 if(window.orientation == 90 || window.orientation == -90){ 8 alert("横屏状态!") 9 } 10 window.addEven

JavaScript判断横屏/竖屏

/判断手机横竖屏状态:  function hengshuping(){    if(window.orientation==180||window.orientation==0){          alert("竖屏状态!")            }  if(window.orientation==90||window.orientation==-90){          alert("横屏状态!")              }   }  window.a

用JavaScript判断横屏竖屏问题。JavaScript代码如下【转】

/判断手机横竖屏状态: function hengshuping(){ if(window.orientation==180||window.orientation==0){ alert("竖屏状态!") } if(window.orientation==90||window.orientation==-90){ alert("横屏状态!") } } window.addEventListener("onorientationchange" in

css3完美解决手机横竖屏判断,让用户看邀请函更爽

html: <div id="cover1"></div> <p id="cover1w">亲,请竖屏观看本屏内容,谢谢^_^</p> css: /* 判断手机横竖屏  */ @media screen and (orientation:portrait) { /*  css[竖向定义样式]  */ #cover1{display: none;width: 100%;height: 100%;background-co

javascript判断手机旋转横屏竖屏

javascript判断手机旋转横屏竖屏 // 横屏竖屏函数 function orientationChange(){ switch(window.orientation) { case 0: // Portrait case 180: // Upside-down Portrait //Javascript to setup Portrait view window.location.reload(); break; case -90: // Landscape: turned 90 deg