tags:

views:

52

answers:

3

How to add and run a javascript for only on firefox not on others?

I've to add a javascript on a page and it should only work on firefox. not on IE

+1  A: 

use navigator object

navigator.appName

Returns the official name of the browser.

rahul
A: 

Aside from using navigator.appName, you could use the browser detection script from Quirksmode, then use an if statement to check if it's Firefox. This will nicely prepare browser information in an object for you, so you can pick out individual information such as version number, etc.

Andy E
+2  A: 

Never use browser detection, use object detection (if your intent was using some objects/methods available only on some browsers.)

N 1.1