Created
January 15, 2016 07:46
-
-
Save RhinoLu/079f75c115b024dcbb07 to your computer and use it in GitHub Desktop.
js get android version
This file contains hidden or 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
// http://stackoverflow.com/questions/7184573/pick-up-the-android-version-in-the-browser-by-javascript | |
function getAndroidVersion(ua) { | |
ua = (ua || navigator.userAgent).toLowerCase(); | |
var match = ua.match(/android\s([0-9\.]*)/); | |
return match ? match[1] : false; | |
}; | |
getAndroidVersion(); //"4.2.1" | |
parseInt(getAndroidVersion(), 10); //4 | |
parseFloat(getAndroidVersion()); //4.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment