I'm trying to use this line to detect browser type: IE or Firefox.
alert(isBrowser("Microsoft"));
but I get absolutely nothing, the alert doesn't even pop up. Not sure what I'm doing wrong.
What would be the best practice way to detect browser type?
How to detect the user browser ( Safari, Chrome, IE, Firefox and Opera ) using JavaScript ? The browser on which the current page is opening can be checked using JavaScript. The userAgent property of the navigator object is used to return the user-agent header string sent by the browser.
Answer: To establish the actual name of the user's Web browser, you can use the navigator. appName and navigator. userAgent properties.
It is used for returning the name of the browser. It is a read-only property and the values returned by it varies from browsers to browsers. it returns a string which represents the name of the browser.
In the browser window, hold the Alt key and press H to bring up the Help menu. Click About Google Chrome and locate the version at the top of the window that appears.
I hope this helps:
http://www.quirksmode.org/js/detect.html
(it's a long script, so i don't want to post it here)
Try this:
alert(navigator.appName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With