I can not detect MS Explorer using any form of JavaScript

Clash Royale CLAN TAG#URR8PPP
I can not detect MS Explorer using any form of JavaScript
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() 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?
1 Answer
1
It takes a simple JS script to accomplish this for any borwser out there that supports JS.
For IE:
function isIE()
ua = navigator.userAgent;
var is_ie = ua.indexOf("MSIE ") > -1
if (isIE())
alert('It is InternetExplorer');
else
alert('It is NOT InternetExplorer');
Hope this helps.
It worked! Well, I will have to break your code down to figure out why yours works and not mine. Thank you very much.
– Niel-A
Aug 10 at 19:49
You are very welcome. You never defined ms_ie in your code - that is probably where you went wrong.
– JKimbrough
Aug 10 at 21:25
One other thing. Why can't I eliminate the else statement and still have it work. I have never seen anything like this. Makes no sense
– Niel-A
Aug 10 at 22:10
I had not realized that I was in Edge not explorer.
– Niel-A
Aug 24 at 23:05
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Possible duplicate of How to detect Safari, Chrome, IE, Firefox and Opera browser?
– Luca Kiebel
Aug 10 at 17:26