Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using javascript to detect browser type [duplicate]

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?

like image 827
Duber Avatar asked Mar 22 '10 06:03

Duber


People also ask

How do you detect which browser is being used JavaScript?

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.

How can you detect the client's browser name in JavaScript?

Answer: To establish the actual name of the user's Web browser, you can use the navigator. appName and navigator. userAgent properties.

What is navigator appName in JavaScript?

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.

How do I identify my 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.


2 Answers

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)

like image 180
lajuette Avatar answered Sep 23 '22 15:09

lajuette


Try this:

alert(navigator.appName);
like image 31
Darin Dimitrov Avatar answered Sep 22 '22 15:09

Darin Dimitrov