获得真正的iphone分辨率- jquery



我正在编写一个jQuery插件,它需要精确的屏幕分辨率。

众所周知,iphone的响应是320*480 (iphone 4),但我需要正确的尺寸(视网膜尺寸)。

当然,视网膜ipad也存在这个问题。

在这种情况下我该怎么做?

感谢您的回复。

/编辑

好的,我已经做了,但是我认为有一个错误

我的脚本:

var screenWidth = $(window).width() * window.devicePixelRatio;
var screenHeight = $(window).height() * window.devicePixelRatio;
i get the following values:
portrait:
screenWidth = 640
screenHeight = 960
landscape:
screenWidth = 960
screenHeight = 960

与以下元标签:

meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=no"

在webkit浏览器中,您可以使用window.devicePixelRatio获得设备像素比。将它乘以分辨率,你应该得到你想要的数字。

你应该把它乘以2,你会得到真正的分辨率。http://smartphones.techcrunch.com/q/152/4793/What-are-the-specifications-of-the-Apple-iPhone-4S-smartphone

最新更新