Last active
December 18, 2015 11:19
-
-
Save dwolfhub/5774898 to your computer and use it in GitHub Desktop.
Javascript: Detect IE and Return 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
/** | |
* Detect IE and Return Version | |
* @return {int} 0 if not IE, version if IE | |
*/ | |
function ieVersion() { | |
var rv = 0; // Return value assumes failure. | |
if (navigator.appName == 'Microsoft Internet Explorer') | |
{ | |
var ua = navigator.userAgent; | |
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); | |
if (re.exec(ua) != null) | |
rv = parseFloat( RegExp.$1 ); | |
} | |
return rv; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment