Created
April 16, 2015 22:26
-
-
Save pgarciacamou/7fe1a69ec56e2d1e1f85 to your computer and use it in GitHub Desktop.
Get OS version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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