Skip to content

Instantly share code, notes, and snippets.

@rluquero
Forked from miguelmota/detect-ie.js
Created August 24, 2016 15:39
Show Gist options
  • Save rluquero/2c7a639a4f67fc359144c43e3e198417 to your computer and use it in GitHub Desktop.
Save rluquero/2c7a639a4f67fc359144c43e3e198417 to your computer and use it in GitHub Desktop.
Detect IE in JavaScript
function detectIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
var trident = ua.indexOf('Trident/');
if (trident > 0) {
// IE 11
var rv = ua.indexOf('rv:');
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}
var edge = ua.indexOf('Edge/');
if (edge > 0) {
// IE 12
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment