我正在编写一个jQuery插件,需要确切的屏幕分辨率。
众所周知,iPhone 4的响应是320*480,但我需要正确的尺寸(视网膜尺寸)。
当然,这个问题也存在于视网膜iPad上。
在这种情况下我该怎么办?
谢谢你们的回答。
/edit
好了,我已经完成了,但我认为有一个错误。
我的脚本:
使用以下元标签:
众所周知,iPhone 4的响应是320*480,但我需要正确的尺寸(视网膜尺寸)。
当然,这个问题也存在于视网膜iPad上。
在这种情况下我该怎么办?
谢谢你们的回答。
/edit
好了,我已经完成了,但我认为有一个错误。
我的脚本:
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"
$(window).height()
实际上报告浏览器的完整高度而不仅仅是屏幕?尝试使用screen.height * window.devicePixelRatio
,看看是否可以获得更好的结果。 - Jason Whitted