<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Detect IE/Edge Version</title>
</head>
<body>
<header>
<h1>Detectar versiones de IE/Edge</h1>
<h2>Script Javascript para reconocer Internet Explorer hasta 12+ alias Edge.</h2>
</header>
<div class="view">
<section>
<h3 id="resultado">detectando…</h3>
<p id="detalles">n/a</p>
</section>
<footer>
<blockquote cite="https://stackoverflow.com/a/34883022">
<code>var</code> <code>uA = window.navigator.userAgent,</code><br />
   <code>onlyIEorEdge = /msie\s|trident\/|edge\//i.test(uA) && !!( document.uniqueID || window.MSInputMethodContext),</code><br />
   <code>checkVersion = (onlyIEorEdge && +(/(edge\/|rv:|msie\s)([\d.]+)/i.exec(uA)[2])) || NaN;</code>
</blockquote>
</footer>
</div>
</body>
</html>
@import url('https://fonts.googleapis.com/css?family=Dancing+Script');
body {
color: #555;
background-color: #eee;
font-weight: 300;
margin: 0;
padding: 1rem 3rem;
box-align: center;
flex-align: center;
align-items: center;
display: box;
display: flexbox;
display: flex;
box-orient: vertical;
box-direction: normal;
flex-direction: column;
flex-direction: column;
font-family: 'Dancing Script', cursive;
box-pack: center;
flex-pack: center;
justify-content: center;
min-height: 100vh;
}
h1 {
text-align: center;
font-size: 3rem;
line-height: 4rem;
}
h2{
color: darkgrey;
font-size: 1.8rem;
text-align: center;
font-size: 100;
}
h3 {
color: white;
text-align: center;
font-weight: 300;
font-size: 3rem;
}
p {
text-align: center;
font-family: "Fira Mono", monospace;
font-size: 1rem;
line-height: 1.5rem;
}
.view{
background: #1b2836;
color: color: #fff;
min-height: 10rem;
padding: 1rem;
box-shadow: 15px 15px 3px rgba(0, 0, 0, 0.3);
font-family: 'Open Sans', sans-serif;
margin: 2rem auto 1.6rem;
max-width: 100%;
}
#detalles{
color: #8899a6;
}
blockquote{border-left:1em solid #555;margin:1.5em 1em;padding:.5em 1em;quotes:"\201C""\201D";}
blockquote:before{color:#808080;content:open-quote;font-size:4em;line-height:.1em;margin-right:.25em;vertical-align:-.4em;}
blockquote :first-child{display:inline;}
blockquote :last-child{margin-bottom:0;}
/******
Detecting Windows Internet Explorer and Microsoft Edge More Effectively
@author: Pedro Macedo Minchán
@thread: https://stackoverflow.com/a/34883022
@inspired: https://codepen.io/gapcode/pen/vEJNZN
@inspired: https://gist.github.com/jalbertbowden/5174156
@date: 26-05-2017/UTC-05
@update: 31/05/2017
@ver: 0.8
@URL: http://jsfiddle.net/Webnewbie/apa1nvu8/embedded/
@test: IE[4-11] && Edge12+
@Works on AllStandardMode and in CompatibilityMode <=IE11:
var IE_lte_10 = ( !!document.all && +( /msie\s(\d+)/i.exec( window.navigator.userAgent )[1] ) ) || NaN; // No works in EdgeHTML Mode
var IE_11 = ( !!window.MSInputMethodContext && "ActiveXObject" in window && +(/trident(?:.*rv:([\d.]+))?/i.exec( window.navigator.userAgent)[1] ) ) || NaN; // No works in EdgeHTML Mode
var EDGE_gte_12 = ( !!window.MSInputMethodContext && !document.uniqueID && +(/Edge\/(\d+)/i.exec( window.navigator.userAgent)[1] ) ) || NaN;
*******/
//All Standards and Compatibility Mode
var uA = window.navigator.userAgent,
onlyIEorEdge = /msie\s|trident\/|edge\//i.test(uA) && !!( document.uniqueID || window.MSInputMethodContext),
checkVersion = (onlyIEorEdge && +(/(edge\/|rv:|msie\s)([\d.]+)/i.exec(uA)[2])) || NaN,
result = document.getElementById('resultado');
document.getElementById('detalles').innerHTML = uA;
result.innerHTML = !isNaN(checkVersion) ? 'You\'re using ' + (checkVersion >= 12 ? 'Microsoft Edge ' : 'Windows Internet Explorer ') + checkVersion : 'You\'re not using Microsoft\'s Browser.';
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |