noo*_*ber 3 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>
Run Code Online (Sandbox Code Playgroud)
输出:
W = 981&H = 425
为什么?维基百科说,w应该是960.
问候,
UPDATE
我发现,问题与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>
Run Code Online (Sandbox Code Playgroud)
看看这个元:
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设备使用相同的解决方案吗?
提前致谢!
cal*_*sto 16
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也相似.