Skip to content

Instantly share code, notes, and snippets.

@Jibbarth
Last active April 4, 2017 10:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Jibbarth/1ebb107379b4ff515cd64ef4fcd529df to your computer and use it in GitHub Desktop.
Get Internet Explorer version and get is Edge Navigator in javascript
/**
* Gets the internet explorer version.
*
* @return {int} The internet explorer version.
*/
function getInternetExplorerVersion() {
var rv = -1;
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);
}
} else if (navigator.appName == 'Netscape') {
var ua = navigator.userAgent;
var re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null) {
rv = parseFloat(RegExp.$1);
}
}
return rv;
}
/**
* Determines if edge navigator.
*
* @return {boolean} True if edge navigator, False otherwise.
*/
function isEDGENavigator(){
var isEdge = false;
if(navigator.appName == "Netscape"){
isEdge = (navigator.appVersion.indexOf('Edge') > -1);
}
return isEdge;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment