Skip to content

Instantly share code, notes, and snippets.

@ofstudio
Created June 16, 2014 19:02
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 ofstudio/6b4f0ae057a18e0c97cd to your computer and use it in GitHub Desktop.
Save ofstudio/6b4f0ae057a18e0c97cd to your computer and use it in GitHub Desktop.
ieVersion.js - returns version of Internet Explorer
/**
*
* Returns the version of Internet Explorer
* or undefined if no Internet Explorer detected
* Tested in IE8 ... IE11
*
* http://stackoverflow.com/a/20815285/3071651
*
*/
function ieVersion () {
var iev,
ieold = (/MSIE (\d+\.\d+);/.test(navigator.userAgent)),
trident = !!navigator.userAgent.match(/Trident\/7.0/),
rv = navigator.userAgent.indexOf("rv:11.0");
if (ieold) { iev = Number(RegExp.$1); }
if (navigator.appVersion.indexOf("MSIE 10") !== -1) { iev = 10; }
if (trident && rv !== -1) { iev = 11; }
return iev;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment