Created
June 27, 2013 03:11
-
-
Save rafaelrinaldi/5873671 to your computer and use it in GitHub Desktop.
Checks which iOS version is running.
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
// http://stackoverflow.com/a/14223920/339827 | |
function iOSVersion() { | |
var match = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/), | |
version = [ | |
parseInt(match[1], 10), | |
parseInt(match[2], 10), | |
parseInt(match[3] || 0, 10) | |
]; | |
return parseFloat(version.join('.')); | |
} |
Hi @lennybacon, I'd suggest tweaking that to, if(window.MSStream), having just tested that code on iphone 5 s and it returns false.
function iOSVersion() {
if(window.MSStream){
// There is some iOS in Windows Phone...
// https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
return false;
}
var match = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/),
version;
if (match !== undefined && match !== null) {
version = [
parseInt(match[1], 10),
parseInt(match[2], 10),
parseInt(match[3] || 0, 10)
];
return parseFloat(version.join('.'));
}
return false;
}
match returns only array or null
can I use this to detect ios 12 version? will it work?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Plus detect Microsoft Internet Explorer on a Windows Mobile...