Skip to content

Instantly share code, notes, and snippets.

@istro
Forked from Craga89/ios-version.js
Created February 14, 2013 22:03
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 istro/4956810 to your computer and use it in GitHub Desktop.
Save istro/4956810 to your computer and use it in GitHub Desktop.
/*
* Outputs a float representing the iOS version if user is using an iOS browser i.e. iPhone, iPad
* Possible values include:
* 3 - v3.0
* 4.0 - v4.0
* 4.14 - v4.1.4
* false - Not iOS
*/
var iOS = parseFloat(
('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1])
.replace('undefined', '3_2').replace('_', '.').replace('_', '')
) || false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment