Skip to content

Instantly share code, notes, and snippets.

@ptb
Created January 8, 2013 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptb/4487675 to your computer and use it in GitHub Desktop.
Save ptb/4487675 to your computer and use it in GitHub Desktop.
Javascript function returns an array of iOS 2.0 and later version integers.
var iOSversion = function() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment