I have tried several ways to detect MS Explorer with JavaScript but failed. Used alert in JavaScript without using codes for detecting Explorer and the JavaScript works. Why can't any of my codes work on any browsers?
var isIE = /*@cc_on!@*/false;
window.onload = function() {
var ua = window.navigator.userAgent;
ms_ie = /MSIE|Trident/.test(ua);
if ( ms_ie ) {
window.alert("This Explorer");
}
}
I tried several ways to detect MS Explorer using JavaScript.I used alert... in JavaScript and it worked. It works as long as I do not try to detect Explore. What am I doing wrong?