Created
June 2, 2012 08:15
-
-
Save ngoclt/2857281 to your computer and use it in GitHub Desktop.
Check iOS version with Javascript
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
checkVersion = function () { | |
var agent = window.navigator.userAgent, | |
start = agent.indexOf( ‘OS ‘ ); | |
if( ( agent.indexOf( ‘iPhone’ ) > -1 || agent.indexOf( ‘iPad’ ) > -1 ) && start > -1 ){ | |
return window.Number( agent.substr( start + 3, 3 ).replace( ‘_’, ’.’ ) ); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
let checkVersion = () => /(iPhone|iPad) OS ([1-9]*)/g.exec(window.navigator.userAgent)?.[2] || 0