Skip to content

Instantly share code, notes, and snippets.

@atatos
Created September 20, 2013 10:45
Show Gist options
  • Save atatos/6635823 to your computer and use it in GitHub Desktop.
Save atatos/6635823 to your computer and use it in GitHub Desktop.
detect IOS version upper or lower than 5
function iOSversion() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
}
var ver = iOSversion();
if (ver && ver[0] <= 5) {
console.log("ok, ios 5 or later");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment