web-applications - iPhone 4网络应用程序浏览器宽度: 960 or 981?

标签 web-applications width iphone-4

<html>
    <body REMonload="document.location.assign('index2.php?w=' + window.innerWidth + '&h=' + window.innerHeight);">
    <script language="javascript">
    document.write('w=' + window.innerWidth + '&h=' + window.innerHeight);
    </script>
    </body>
</html>

输出:

w=981&h=425

为什么?维基百科说,w 应该是 960。

问候,

更新

我发现,问题与视口(viewport)元标记有关。

以下代码实现了我想要看到的功能:

<html style="width:100%; height:100%;">
<head>
<meta name="viewport" content="width=device-width; initial-scale=0.5; minimum-scale=0.5; maximum-scale=0.5; user-scalable=no;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
</head>
    <body style="width:100%; height:100%; background-color: blue;"
    REMonload="document.location.assign('index2.php?w=' + window.innerWidth + '&h=' + window.innerHeight);"
    onload="alert('w=' + window.innerWidth + '&h=' + window.innerHeight);">
    </body>
</html>

看看这个元数据:

name="viewport"content="width=device-width;initial-scale=0.5;minimum-scale=0.5;maximum-scale=0.5;user-scalable=no;"

我不明白,它是如何工作的。我尝试过将设备宽度系数设置为 1.0(我想是 960),但似乎 0.5 就是我所需要的。

无论如何,它适用于我的 iPod Touch 4 (960*640)。

您可以在 iPad 或 iPad2 以及 iPhone/iPod Touch 1 或 2 或 3 上尝试一下该代码吗?是1024/768和480/320对应的吗?换句话说,我可以对任何 Apple 设备使用相同的解决方案吗?

提前致谢!

最佳答案

iPhone 3GS:
1.风景:w=960 h=416
2.人像:w=640 h=712

iPhone 4:
1.风景:w=960 h=416
2.人像:w=640 h=712

iPad 1
1.风景:w=2048 h=1344
2.人像:w=1536 h=1856

iPad 2
1.风景:w=2048 h=1344
2.人像:w=1536 h=1856

编辑:添加3GS数据
edit2:添加了ipad2数据

看看你和我的结果,我想说后来的 iPhone 和 iPod touch 看起来是一样的,而且两款 iPad 也很相似。

关于web-applications - iPhone 4网络应用程序浏览器宽度: 960 or 981?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7946583/

相关文章:

mysql - 如何在网络应用程序中实时/快速处理 GPS 数据?

javascript - 根据子 div 的总数更改宽度

iPhone 4 Nib 尺寸

ios - 如何在 iOS6 模拟器中测试使用 iPhone 5 屏幕尺寸创建的应用程序?

用于高级用户帐户保护的 Java 库

php - 如何更改php中的 session 范围?

css - 如何根据屏幕宽度计算 CSS 缩放因子?

iphone - Facebook 登录后应用程序崩溃

java - Spring Controller 请求映射未被识别

css - 100% 宽度 + 水平和垂直滚动