iPhone 4 Web应用程序浏览器宽度:960或981? [英] iPhone 4 web-app browser width: 960 or 981?
问题描述
<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=981&h=425
为什么?维基百科说,w应该是960.
Why? Wikipedia says, w should be 960.
此致
更新
我发现,问题与 viewport 元标记有关.
I've found out, the problem was related to viewport meta tag.
以下代码可以实现我想要的功能:
The following code does what I want to see:
<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>
查看此meta:
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.
I don't understand, how does it work. I've tried coefficient 1.0 for device-width (I suppose it's 960), but it seems like 0.5 is what I need.
无论如何,它适用于我的iPod Touch 4(960 * 640).
Anyway, it works for my iPod Touch 4 (960*640).
您能否在iPad或iPad2和iPhone/iPod Touch 1或2或3上尝试使用该代码?分别是1024/768和480/320吗?换句话说,我可以在任何Apple设备上使用相同的解决方案吗?
Could you please try the code on iPad or iPad2 and iPhone/iPod Touch 1 or 2 or 3? Is it 1024/768 and 480/320 correspondingly? In other words, can I use the same solution for any Apple device?
提前谢谢!
推荐答案
iPhone 3GS:
1.风景:w = 960 h = 416
2.肖像:w = 640 h = 712
iPhone 3GS:
1. Landscape: w=960 h=416
2. Portrait: w=640 h=712
iPhone 4:
1.风景:w = 960 h = 416
2.肖像:w = 640 h = 712
iPhone 4:
1. Landscape: w=960 h=416
2. Portrait: w=640 h=712
iPad 1
1.景观:w = 2048小时= 1344
2.肖像:w = 1536 h = 1856
iPad 1
1. Landscape: w=2048 h=1344
2. Portrait: w=1536 h=1856
iPad 2
1.景观:w = 2048小时= 1344
2.肖像:w = 1536 h = 1856
iPad 2
1. Landscape: w=2048 h=1344
2. Portrait: w=1536 h=1856
添加了3GS数据
edit2:添加了ipad2数据
edit: added 3GS data
edit2: added ipad2 data
从我的角度来看您的研究结果,我想说以后的iPhone和iPod touch看起来是一样的,而且两个iPad也彼此相似.
Looking at your results together with mine, I'd say the later iPhones and iPod touch seem the same, and both iPads are also similar to each other.
这篇关于iPhone 4 Web应用程序浏览器宽度:960或981?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!