Skip to content

Instantly share code, notes, and snippets.

@yelban
Forked from ngoclt/checkVersion.js
Created October 27, 2020 02:47
Show Gist options
  • Select an option

  • Save yelban/8c62a900f9cda96f2e30e7f0ac2089ce to your computer and use it in GitHub Desktop.

Select an option

Save yelban/8c62a900f9cda96f2e30e7f0ac2089ce to your computer and use it in GitHub Desktop.
Check iOS version with Javascript
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