Detect Whether it’s Internet Explorer using JavaScript

Detect Whether it’s Internet Explorer using JavaScript

I decided to share a useful one-row snippet for web developers, which can save time and complexity using JavaScript that checks whether the browser that runs the code is MSIE (Internet Explorer) and determine its version.

1
var MSIE = parseInt(window.navigator.userAgent.split("MSIE ")[1]) || false;

Now the MSIE variable holds the version of the IE browser, or false in case of other browser.

1
2
3
4
// i.e. atob() function supported on all browsers except IE9 and lower.
if ( !MSIE || MSIE > 9 ) {
    alert(atob("WW91J3JlIEF3ZXNvbWUh"));
}

Enjoy!

1 comment(s)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.