Jump to content

browser detection


mwbarry

Recommended Posts

I'm trying to write a script that will determine which browser the viewer is using in order to slightly change the CSS accordingly to make up for display differences in each browser.I had thought using the items from here would work. I was specifically hoping to use navigator.appName which I thought would tell me 'Firefox' or 'Safari' and then passing that value into a js function. However in all browsers I get the same values for all paramaters except for when I check through Opera.Why are they all the same?What is a different method to write a browser detection script?

Link to comment
Share on other sites

1. Don't do it. Spend more time learning the ins and outs of CSS. It really can be done.2. The data you want can be extracted from navigator.userAgent . The strings contain a lot more data than you need, so you'll need a regex. Look at all of them to see which string fragments always work.

Link to comment
Share on other sites

Browser sniffing is a nasty habit to get into. Like DD said, find a way to do it with CSS. There's almost always a fully cross-browser technique (even for IE). And on the rare occasions there isn't a cross-browser technique, 99 times out of 100 it's IE that misbehaves and for that there's IE conditional comments.

Link to comment
Share on other sites

seems like SM gave you a good answer. He was able to solve the problem by adding a DTD. Did you do that? Did it not work?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...