Detect between the iPad and iPad2 via Jquery / Javascript?

限于喜欢 提交于 2020-01-02 08:40:08

问题


Is there anyway to detect between the iPad and iPad2 via Jquery / Javascript? Or even PHP or some other way from a website?


回答1:


I have an iPad and an iPad2 with the same iOS version and i don't this this is currently possible it's producing the same exact user agent on both devices.

iPad

Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3

iPad2

Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3



回答2:


The javascript user agent Mobile string (Mobile/9A405) seems to be dependent on the CPU OS version. So, while some places it may differ by iPad generation, it's often because the CPU OS version is different.

EXAMPLE 1 - different CPU OS = different Mobile/string:

  • iPad 1 - Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48:3

  • iPad 2 - Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48:3

EXAMPLE 2 - same CPU OS = same Mobile/string:

  • iPad 1 - Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3

  • iPad 2 - Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3




回答3:


As you can see below the only difference is ipad:Mobile/8F190 ipad2:Mobile/8F191 so it is possible to chop down the user agent and look for the difference.

The iPad user agent string:

Mozilla/5.0 (iPad; U; CPU OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F190 Safari/6533.18.5

The iPad2 user agent string:

Mozilla/5.0 (iPad; U; CPU OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.5

but i very much doubt there is much difference between the versions of safari, perhaps your just looking to notify the user, that one has more money then the other ;p...




回答4:


There are differences which are important, like the camera. For instance I would like to detect a user is on an ipad and not even present the camera button, but if a user is on an ipad2 I will show the camera icon and they can use the camera.

All I can do right now is to call the method to take a picture and if I get an error assume it is an ipad.



来源:https://stackoverflow.com/questions/6230243/detect-between-the-ipad-and-ipad2-via-jquery-javascript

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