# how to detect Internet Explorer browser using JavaScript

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Oct 4, 2020, updated Sep 23, 2021. Topics: JavaScript.
Canonical URL: https://attacomsian.com/blog/javascript-dom-detect-internet-explorer-browser

> Learn how to detect whether the current browser is Internet Explorer or not in vanilla JavaScript.

To detect whether the current browser is Internet Explorer, you can make use of the `navigator.userAgent` property.

The `userAgent` property returns the value of the `user-agent` header sent by the browser to the server. It contains information about the name, version, and platform of the browser.

The following example demonstrates how you can use `navigator.userAgent` to identify whether the current browser is Internet Explorer:

```javascript
const isIE = () => {
    const ua = navigator.userAgent;
    return ua.indexOf('MSIE') > -1 || ua.indexOf('Trident') > -1;
};
```

Alternatively, you could also use the `document.documentMode` property. It only works in IE 5-11 and returns an integer indicating the mode used by the IE browser to render the current document:

```javascript
const isIE = !!document.documentMode;
```
