在javascript中获取与方向相关的屏幕尺寸(IPad)

在javascript中获取与方向相关的屏幕尺寸(IPad),javascript,ipad,dimensions,Javascript,Ipad,Dimensions,我试图在IPad上获得屏幕尺寸 $wnd.screen.width $wnd.screen.height 当我处于横向模式时,尺寸返回768x1024。这不是我所期望的。如何获得1024x768的真实尺寸 注意:我没有改变方向,我从横向模式开始并保持该模式。当你改变方向时,iPad喜欢做一些有趣的缩放动作 您可以使用标记解决其中许多问题,例如: <meta name="viewport" content="user-scalable=no,initial-scale=1.0, minim

我试图在IPad上获得屏幕尺寸

$wnd.screen.width $wnd.screen.height

当我处于横向模式时,尺寸返回768x1024。这不是我所期望的。如何获得1024x768的真实尺寸


注意:我没有改变方向,我从横向模式开始并保持该模式。

当你改变方向时,iPad喜欢做一些有趣的缩放动作

您可以使用
标记解决其中许多问题,例如:

<meta name="viewport" content="user-scalable=no,initial-scale=1.0,
 minimum-scale=1.0,maximum-scale=1.0">

当你改变方向时,iPad喜欢通过缩放来做有趣的事情

您可以使用
标记解决其中许多问题,例如:

<meta name="viewport" content="user-scalable=no,initial-scale=1.0,
 minimum-scale=1.0,maximum-scale=1.0">

作为最简单的解决方案,如果宽度小于高度,请交换宽度和高度,以便始终获得横向模式的分辨率

function getResolution(){
    return {
        width: $wnd.screen.width < $wnd.screen.height
             ? $wnd.screen.height
             : $wnd.scree.width,
        height: $wnd.screen.height > $wnd.screen.width
             ? $wnd.screen.width
             : $wnd.scree.height
    };
}
函数getResolution(){ 返回{ 宽度:$wnd.screen.width<$wnd.screen.height ?$wnd.screen.height :$wnd.scree.width, 高度:$wnd.screen.height>$wnd.screen.width ?$wnd.screen.width :$wnd.scree.height }; }
作为最简单的解决方案,如果宽度小于高度,请交换宽度和高度,以便始终获得横向模式的分辨率

function getResolution(){
    return {
        width: $wnd.screen.width < $wnd.screen.height
             ? $wnd.screen.height
             : $wnd.scree.width,
        height: $wnd.screen.height > $wnd.screen.width
             ? $wnd.screen.width
             : $wnd.scree.height
    };
}
函数getResolution(){ 返回{ 宽度:$wnd.screen.width<$wnd.screen.height ?$wnd.screen.height :$wnd.scree.width, 高度:$wnd.screen.height>$wnd.screen.width ?$wnd.screen.width :$wnd.scree.height }; }