手机横屏问题

function orient() {

var supportOrientation = (typeof window.orientation === 'number' &&

            typeof window.onorientationchange === 'object');

var orientation;

if(supportOrientation){

        orientation = window.orientation;

        switch(orientation){

            case 90:

            case -90:

                orientation ='landscape';

               

                break; 

            default:

                orientation ='portrait';

                break;

        }

    }else{

        orientation = (window.innerWidth > window.innerHeight) ? 'landscape' : 'portrait';

    }

    if(orientation == 'landscape'){


    $(".WScalet").css({"zoom":window.innerWidth/1136});

        

    }

    if(orientation == 'portrait'){

   

    $(".WScale").css({"zoom":window.innerWidth/640});  

       


    }

}

//页面加载时调用

$(function(){

orient();

});

//用户变化屏幕方向时调用

$(window).bind( 'orientationchange', function(e){

orient();

});

我这样做为什么每次转屏后都要刷新才能正常显示

lyhzwf
浏览 1118回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript