I have googled and and tried many ideas but they either mess up the entire site on all browsers, or they are really old, or they are javascript and not jQuery. I am exhausted.
Currently this works for detection IOS, but not a version:
$(document).ready(function() {
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if (agentID) {
... do something here
}
});
How can I add just IOS 8 detection inside this so I can just create an html class "ios-8" "no-ios8" or equivalent.
Mobile Safari's UA string looks like this:
Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A405 Safari/600.1.4
(Source: http://whatsmyuseragent.com/)
So you could write a function like this. (DEMO)
var isIOS8 = function() {
var deviceAgent = navigator.userAgent.toLowerCase();
return /(iphone|ipod|ipad).* os 8_/.test(deviceAgent);
}
alert("isIOS8: " + isIOS8());
Visit the demo page in a mobile safari browser, or webview app like iOS Chrome, to see it alert true
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With