JSFiddle - React, Tailwind, and code Playground
by James Peter
HTML
<h1>
Detectando Windows Internet Explorer a partir de sus características.
</h1>
<h2 id="resultado">detectando...</h2>
CSS
body {
color: black;
background-color: white;
font-family: "Fira Sans", sans-serif;
font-weight: 300;
margin: 0;
padding: 3rem;
}
h1 {
color: darkgrey;
text-align: center;
font-weight: 300;
font-size: 1.5rem;
line-height: 2rem;
}
h2 {
text-align: center;
font-weight: 300;
font-size: 4rem;
}
JavaScript
/******
Detecting Windows Internet Explorer with
characteristics
@author: Pedro Macedo Minchán
@thread: https://stackoverflow.com/a/34883022
@inspired: https://codepen.io/gapcode/pen/vEJNZN
@date: 26-05-2017/UTC-05
@ver: 0.9
@test:
*******/
var browserVersionExplorer = (function() {
var ie = '<s>NotIE</s>',
me = '<s>NotIE</s>';
if (/msie\s|trident\/|edge\//i.test(window.navigator.userAgent) && !!(document.documentMode || document.uniqueID || window.ActiveXObject || window.MSInputMethodContext)) {
if (!!window.MSInputMethodContext) {
ie = !("ActiveXObject" in window) ? 'EDGE' : 11;
} else if (!!document.uniqueID) {
if (!!(window.ActiveXObject && document.all)) {
if (document.compatMode == "CSS1Compat" && !!window.DOMParser ) {
ie = !!window.XMLHttpRequest ? 7 : 6;
} else {
ie = !!(window.createPopup && document.getElementById) ? parseFloat('5.5') : 5;
}
if (!!document.documentMode && !!document.querySelector ) {
ie = !!(window.atob && window.matchMedia) ? 10 : ( !!document.addEventListener ? 9 : 8);
}
} else ie = !!document.all ? 4 : (!!window.navigator ? 3 : 2);
}
}
return ie > 1 ? 'IE ' + ie : ie;
})();
document.getElementById('resultado').innerHTML = browserVersionExplorer;