Skip to content

Instantly share code, notes, and snippets.

@franklinjavier
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save franklinjavier/d883dc145c11f4725c86 to your computer and use it in GitHub Desktop.

Select an option

Save franklinjavier/d883dc145c11f4725c86 to your computer and use it in GitHub Desktop.
Detect IE version
/**
* Detect if the browser is an IE
*
* @return int
*/
var isie = (function() {
return navigator.appName.toLowerCase() === 'microsoft internet explorer';
}());
/**
* Detect the version
*
* @return int
*/
var version = (function() {
var rv = false;
if (isie) {
var ua = navigator.userAgent;
if (/MSIE ([0-9]{1,}[.0-9]{0,})/.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