在 jQuery if/then 语句中识别 iOS 用户代理的简单方法?
就像听起来一样..
有没有一些神奇而简单的方法可以说:
if (user agent is iOS) {
if (browserRatio >=1.5) {
$container.css('min-height', '360px');
} else {
$container.css('min-height', '555px');
}
}
Exactly like it sounds..
Is there some magical and easy way to say:
if (user agent is iOS) {
if (browserRatio >=1.5) {
$container.css('min-height', '360px');
} else {
$container.css('min-height', '555px');
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
找到了。
Found it.
我知道您特别询问 jquery,但 IMO,您几乎肯定想使用 CSS3 < code>@media 查询 为此。甚至支持测试横向或纵向。
希望这有帮助!
I know you're asking about jquery in particular, but IMO, you almost certainly want to use CSS3
@media
queries for this. There's even support for testing for landscape or portrait orientation.Hope this helps!
为了让它工作,你需要定义 browserWidth,但是它会工作。这里我只针对 iPad。
In order for this to work you are going to need to define browserWidth, but yes it will work. Here I targeted iPad only.
对于网络应用程序版本,请尝试此。
For web app version try this.
要确保此字符串不匹配:
Mozilla/5.0(Mobile;Windows Phone 8.1;Android 4.0;ARM;Trident/7.0;Touch;rv:11.0;IEMobile/11.0;NOKIA;Lumia 925),例如 iPhone OS 7_0_3 Mac OS X AppleWebKit/537(KHTML,如 Gecko)Mobile Safari/537
只需更改你的代码To make sure this string doesn't get matched:
Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 925) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537
just change your code to根据我之前的回答的评论,听起来真正的问题是“如何在 iPhone 中隐藏 URL 栏”。对于这个问题,我发现了这个:
如何在 MobileSafari 中隐藏地址栏:
Based on comments to my previous answer, it sounds like the real question is, "how do you hide the URL bar in an iPhone". To that question, I found this:
How to Hide the Address Bar in MobileSafari: