Skip to content

Instantly share code, notes, and snippets.

@kanedo
Created August 25, 2012 16:07
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 kanedo/3467420 to your computer and use it in GitHub Desktop.
Save kanedo/3467420 to your computer and use it in GitHub Desktop.
var mobileVersion = function(){
var version = 0.0;
if(isMobile.iOS()){
version = parseFloat(
('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1])
.replace('undefined', '3_2').replace('_', '').replace('_', '')
) || false;
}
if(isMobile.Android()){
version = navigator.userAgent.match(/Android\s+([\d\.]+)/);
if(version[1] != undefined){
version = version[1];
version = version.replace(/\./gi,'');
while(version.length < 3){
version += "0";
}
}
}
return version; // 4.0.4 == 404
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment