Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在横向模式下启动时出现Jquery mobile方向更改错误_Android_Jquery_Jquery Mobile_Orientation Changes - Fatal编程技术网

Android 在横向模式下启动时出现Jquery mobile方向更改错误

Android 在横向模式下启动时出现Jquery mobile方向更改错误,android,jquery,jquery-mobile,orientation-changes,Android,Jquery,Jquery Mobile,Orientation Changes,我有一种应用程序,它的界面取决于方向的改变。因此,我有两个函数用于接口肖像集和景观集。以下是我如何赶上方向更改事件的代码: $(window).on("orientationchange",function(event){ alert(event.orientation); if (event.orientation == 'portrait') { $(portraitSet()); } else

我有一种应用程序,它的界面取决于方向的改变。因此,我有两个函数用于接口肖像集和景观集。以下是我如何赶上方向更改事件的代码:

$(window).on("orientationchange",function(event){
    alert(event.orientation);
        if (event.orientation == 'portrait')
        {
            $(portraitSet());
        }
        else if (event.orientation == 'landscape')
        {
            $(landscapeSet());
        }
});
在以纵向模式启动应用程序时,它工作正常,但当以横向模式启动应用程序并尝试将移动设备设置为纵向模式时,我的alertevent.orientation向我发送消息横向,但移动设备处于纵向模式。我的错误在哪里?

您好,请使用此代码

$(window).resize( function(){
    var height = $(window).height();
    var width = $(window).width();
        if(width>height) {
      // Landscape
          alert("LANDSCAPE");
        } else {
      // Portrait
        alert("PORTRAIT");
        }

       });
如果您需要更多关于启动手机的信息,请检查高度和宽度。