Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

php - Reliable browser detection with javascript?

I have a website, and offcourse like most websites it loads faster in Firefox.

I want to create some form of a bar, which displays on top of my site, whenever a user without FF enters the site. This bar will say something like "Install FF for better performance etc etc..."

How should I do this? Browser detection I guess, but there are tons of different codes out there. Any code you all know that is more reliable, and better to use?

Btw, does anybody know if I need permission from Mozilla to have such a bar on my website?

Thanks

EDIT: FF IS NOT THE FASTEST BROWSER, I GOT IT!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

(Skipping all the arguments on whether what you want to do is a good or a bad thing. Assuming you really like Firefox and want to promote it.)

  1. Use the navigator object to check if the browser is Firefox. navigator.appCodeName, navigator.appName, navigator.appVersion. What you want to do is not a critical part of your website, so you don't need a fail-safe detection method. If it works for over 95% of your targeted users than the method is good.

  2. I doubt you need permission to advertise a free product. Mozilla even encourages you to do so.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...