我搜索并尝试了许多想法,但它们要么在所有浏览器上破坏了整个站点,要么它们非常陈旧,或者它们是javascript而不是jQuery。我累坏了。
目前,这适用于检测IOS,但不适用于版本:
$(document).ready(function() {
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if (agentID) {
... do something here
}
}); 如何在其中添加IOS 8检测,这样我就可以创建html类"ios-8“”no-ios 8“或等效的.。
发布于 2014-10-14 14:38:19
的UA字符串如下所示:
Mozilla/5.0 ( iPhone;CPU iPhone OS 8__2,类似Mac ) AppleWebKit/600.1.4 (KHTML,类似Gecko)版本/8.0Mobile/12A405 Safari/600.1.4
(资料来源:http://whatsmyuseragent.com/)
所以你可以写这样的函数。(DEMO)
var isIOS8 = function() {
var deviceAgent = navigator.userAgent.toLowerCase();
return /(iphone|ipod|ipad).* os 8_/.test(deviceAgent);
}
alert("isIOS8: " + isIOS8());访问移动safari浏览器中的演示页面,或者像iOS Chrome这样的webview应用程序,可以看到它提醒true。
https://stackoverflow.com/questions/26363330
复制相似问题