开发者

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

开发者 https://www.devze.com 2022-12-22 09:48 出处:网络
How to add and run a javascript for only on firefox not on oth开发者_如何学编程ers? I\'ve to add a javascript on a page and it should only work on firefox. not on IENever use browser detection, use o

How to add and run a javascript for only on firefox not on oth开发者_如何学编程ers?

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


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


use navigator object

navigator.appName

Returns the official name of the browser.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消