How to detect Internet Explorer 11 and below versions?

user9678848

I'm wondering how I could detect if the user viewing my website is using Internet Explorer 11 or below versions with Javascript.

It should be compatible and works with all these versions.

How to achieve that ?

Ryan Wilson

Here you go, this should work for you:

//Per Icycool, one liner
//function isIE(){
//                 return window.navigator.userAgent.match(/(MSIE|Trident)/);
//               }

function isIE() {
    const ua = window.navigator.userAgent; //Check the userAgent property of the window.navigator object
    const msie = ua.indexOf('MSIE '); // IE 10 or older
    const trident = ua.indexOf('Trident/'); //IE 11

    return (msie > 0 || trident > 0);
}


//function to show alert if it's IE
function ShowIEAlert(){
    if(isIE()){
       alert("User is using IE");
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to detect touch screen in windows 8.1 on internet explorer 11?

Regular expression to detect Internet Explorer 11

Why does Internet Explorer 11 not detect indexedDB

How to install Internet Explorer (multiple versions)?

How to downgrade from Internet Explorer 11 to Internet Explorer 10?

Internet Explorer 11, how to STYLE readonly?

How to access webcam via Internet Explorer (11)?

how to update internet explorer 11 to the version 11.1155.15063.0

How to target Internet explorer versions greater than or equal to IE 10

sessionStorage in old versions of Internet Explorer

Internet Explorer 11 detection

Reinstall Internet Explorer 11

Internet Explorer 11 ignores

formatBlock in Internet Explorer 11

Detect file download with internet explorer

Why does altering innerText in Internet Explorer (version 11 and below) permanently destroys all descendant text nodes?

How can I make Internet Explorer 6 render Web pages like Internet Explorer 11?

How to return value from window.open in Internet Explorer 11?

How to fix my images so they show in internet explorer 11

How to scroll to an element while keeping it vertically centered in Internet Explorer 11?

How to change the default download directory with IE (Internet Explorer 11)

How to collect only unique values in an Array in Internet Explorer 11 by JavaScript?

How edit enable cipher suites in Internet Explorer 11

How can I target only Internet Explorer 11 with JavaScript?

Angular 2 how to improve DOM painting time on Internet Explorer 11

HTML How to make the datepicker visible on Internet Explorer 11?

How to make this Google Font work on Internet Explorer 11

How to get Internet Explorer 11 updates release notes

How to force Internet Explorer 11 to display image aspect ratio correctly?