Created
February 25, 2014 17:33
-
-
Save tsbits/9213759 to your computer and use it in GitHub Desktop.
JS - Detect iOS Version
This file contains 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 iOSversion() { | |
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)]; | |
} | |
} | |
var version = iOSversion(); | |
if(version[0] > 5) { | |
alert('This is running iOS 6 or later.'); | |
} | |
else{ | |
alert('This is running iOS 5 or earlyer.'); | |
} | |
//FROM | |
//http://stackoverflow.com/questions/10309650/add-elements-to-the-dom-given-plain-text-html-using-only-pure-javascript-no-jqu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment