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");
}
});
如果您需要更多关于启动手机的信息,请检查高度和宽度。