/html-dom /Basic
GitHub 4932★

Detect internet explorer browser

Check if the current browser is Internet Explorer (IE):

const isIe = function () {
const ua = window.navigator.userAgent;
return ua.indexOf('MSIE') > -1 || ua.indexOf('Trident') > -1;
};

We also can rely on document.documentMode. This property indicates the document compatibility mode of the document which is an integer in IE 5-11. Other browsers return undefined.

const isIE = !!document.documentMode;

See also

Follow me on and to get more useful contents.