let ua = window.navigator.userAgent; let msie = ua.indexOf('MSIE '); // IE 10 let trident = ua.indexOf('Trident/'); // IE 11 if (msie > 0 || trident > 0) { // Run function for IE here }