zoukankan      html  css  js  c++  java
  • 移动端横屏(beta)

    <!DOCTYPE html>
    
    <html lang="en">
    
    <head>
    
    <meta charset="UTF-8">
    
    <title>Document</title>
    
    </head>
    
    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
    
    <script>
    
    var orientation=0;
    
    function screenOrientationEvent(){
    
    if(orientation == 0)
    
    {
    
    document.getElementById("change").value="竖";
    
    $("body").css({
    
    'transform':'rotate(90deg)',
    
    '-webkit-transform':'rotate(90deg)',
    
    '-moz-transform':'rotate(90deg)'
    
    });
    
    }
    
    else
    
    {
    
    document.getElementById("change").value="横";
    
    $("body").css({
    
    'transform':'rotate(0deg)',
    
    '-webkit-transform':'rotate(0deg)',
    
    '-moz-transform':'rotate(0deg)'
    
    });
    
    }
    
    }
    
    var innerWidthTmp = window.innerWidth;
    
    //横竖屏事件监听方法
    
    function screenOrientationListener(){
    
    try{
    
    var iw = window.innerWidth;
    
    //屏幕方向改变处理
    
    if(iw != innerWidthTmp){
    
    if(iw>window.innerHeight)
    
    {
    
    orientation = 90;
    
    }
    
    else
    
    {
    
    orientation = 0;
    
    }
    
    //调用转屏事件
    
    screenOrientationEvent();
    
    innerWidthTmp = iw;
    
    }
    
    }
    
    catch(e){alert(e);};
    
    //间隔固定事件检查是否转屏,默认500毫秒
    
    setTimeout("screenOrientationListener()",500);
    
    }
    
    //启动横竖屏事件监听
    
    screenOrientationListener();
    
    </script>
    
    <body onload="screenOrientationEvent()">
    
    <input id="change" type="text" value=""/>
    
    </body>
    
    </html>
    

                                                                                                                                                                                                                                                  

  • 相关阅读:
    转:C/C++基本数据类型所占字节数
    转:为什么C++中空类和空结构体大小为1?
    转:内存字节对齐
    转:100层楼扔两个鸡蛋的问题
    移动互联网
    辗转相除法
    斐波那契数列
    error C2783: 无法为“T”推导 模板 参数
    创新工场和海豚浏览器宣讲会启示
    转:快速排序的一个小问题没想明白,求助各位
  • 原文地址:https://www.cnblogs.com/moustache/p/5497132.html
Copyright © 2011-2022 走看看