How to detect if iPhone has retina display or not?

南笙酒味 提交于 2019-12-07 06:14:07

问题


How can I detect if an iPhone has a retina display or not? Is there a reliable way? Either pure PHP or preferably Zend Framework way of doing this.


回答1:


You must consider the fact that you are trying to get client side information on the server side.

It would seem that you are unable to detect the display with pure PHP or Zend framework.

It furthermore seems like the UserAgent information from the client, that you might access from PHP is based upon the OS, not the hardware, and thusly does not help you.

You might be interested in reading the following article which much more eloquently and thoroughly explains the issues.

http://www.bdoran.co.uk/2010/07/19/detecting-the-iphone4-and-resolution-with-javascript-or-php/

Good luck!




回答2:


i figure it out by this

var retina = window.devicePixelRatio > 1;

if (retina)
{
    // the user has a retina display
}
else
{
    // the user has a non-retina display
}



回答3:


Javascript: window.devicePixelRatio




回答4:


I guess as simple thing as display width detection would be sufficient for such a task, retina display packs so many pixels in the width, that simple check will immediately tell you if its an ordinary display or retina display. PHP does not have such a capability out of a box, but Javascript does.

Here is how :

<script language="Javascript">     
<!--     
document.write('<br>your resolution is' + screen.width + 'x' + screen.height)     
//-->     
</script> 


来源:https://stackoverflow.com/questions/11016339/how-to-detect-if-iphone-has-retina-display-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!