Skip to content

Instantly share code, notes, and snippets.

@pgarciacamou
Created April 16, 2015 22:26
Show Gist options
  • Save pgarciacamou/7fe1a69ec56e2d1e1f85 to your computer and use it in GitHub Desktop.
Save pgarciacamou/7fe1a69ec56e2d1e1f85 to your computer and use it in GitHub Desktop.
Get OS version
function getOSver() {
var ua = navigator.userAgent;
var uaindex, userOS, userOSver;
if(ua.match(/iPad/i) || ua.match(/iPod/i) || ua.match(/iPhone/i)) {
userOS = "iOS";
uaindex = ua.indexOf("OS ");
} else {
userOS = "unknown";
}
if(userOS === "iOS" && uaindex > -1) {
userOSver = ua.substr(uaindex + 3, 3).replace("_", ".");
} else {
userOSver = "unknown";
}
return userOSver;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment