通过 Jquery / Javascript 检测 iPad 和 iPad2 之间?
有没有办法通过 Jquery / Javascript 来检测 iPad 和 iPad2 之间的情况?或者甚至是 PHP 或网站上的其他方式?
Is there anyway to detect between the iPad and iPad2 via Jquery / Javascript? Or even PHP or some other way from a website?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我有一台 iPad 和一台 iPad2,它们的 iOS 版本相同,但我不认为这是目前可能的,它在两台设备上生成完全相同的用户代理。
iPad
iPad2
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
iPad2
javascript 用户代理 Mobile 字符串 (Mobile/9A405) 似乎依赖于 CPU 操作系统版本。因此,虽然某些地方可能因 iPad 一代而异,但通常是因为 CPU 操作系统版本不同。
示例 1 - 不同的 CPU 操作系统 = 不同的手机/字符串:
iPad 1 -
Mozilla/5.0(iPad;CPU OS 5_0_1,如 Mac OS X)AppleWebKit/534.46(KHTML,如 Gecko)版本/5.1 Mobile/9A405 Safari/7534.48:3
iPad 2 -
Mozilla/5.0(iPad;CPU OS 5_1,如 Mac OS X)AppleWebKit/534.46(KHTML,如 Gecko)版本/5.1 Mobile/9B176 Safari/7534.48:3
示例 2 - 相同的 CPU 操作系统 = 相同的手机/字符串:
iPad 1 -
Mozilla/5.0(iPad;CPU OS 5_0_1,如 Mac OS X)AppleWebKit/534.46(KHTML,如 Gecko)版本/5.1 Mobile/9A405 Safari/7534.48.3
iPad 2 -
Mozilla/5.0(iPad;CPU OS 5_0_1,如 Mac OS X)AppleWebKit/534.46(KHTML,如 Gecko)版本/5.1 Mobile/9A405 Safari/7534.48.3
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
正如您在下面看到的,唯一的区别是 ipad:Mobile/8F190 ipad2:Mobile/8F191,因此可以砍掉用户代理并查找差异。
iPad 用户代理字符串:
iPad2 用户代理字符串:
但我非常怀疑那里safari 的版本之间有很大差异,也许你只是想通知用户,一个比另一个有更多的钱;p...
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:
The iPad2 user agent string:
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...
有一些重要的差异,比如相机。例如,我想检测用户在 ipad 上,甚至不显示相机按钮,但如果用户在 ipad2 上,我将显示相机图标,他们可以使用相机。
我现在能做的就是调用拍照方法,如果出现错误,则假设它是 ipad。
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.