在移动 Safari 中检测 iOS5(首选 JavaScript)
iOS5 中引入的新固定定位损坏了我的网络应用程序,我需要一种方法来检测 iOS5 用户。
如何检测iOS5?浏览器代理字符串是什么?首选 JavaScript。谢谢!
The new fixed positioning introduced in iOS5 corrupted my webapp and I need a way to detect iOS5 users.
How can I detect iOS5? What is the browser agent string? JavaScript preferred. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自 SO 问题:iOS 5 用户代理字符串是什么:
iPhone:
iPad:
以下是在 javascript 中测试 ios 5.x 的方法:
From the SO question: What is the iOS 5 user-agent string:
iPhone:
iPad:
And here is way to test for ios 5.x in javascript:
我进一步开发了 chown 的答案,检查任何 iOS5 设备,无论是 5 或 5.0.1 或任何更高版本:
I've developed chown's answer a bit further, with a check for any iOS5 device, be it 5 or 5.0.1 or any later versions:
您可以使用 Modernizr 并检测 Web Workers,因为它们在 iOS 5 之前不可用。您仍需要排除 Android,因为 Android 2.0+ 已支持它们。这将为您提供与 iOS6 的前向兼容性,而使用任何已提供的用户代理解析都无法实现这一点。
You could be using Modernizr and detecting for Web Workers as they were not available prior to iOS 5. You need to still exclude Android as Android 2.0+ has supported them. This will give you forward compatibility with iOS6 which you aren't going to get with either of the user agent parses already provided.
您需要考虑“CPU OS 5_0”和“CPU iPhone OS 5_0”,粗糙且肮脏的正则表达式:
You need to account for "CPU OS 5_0" and "CPU iPhone OS 5_0", rough and dirty regex: