mwbarry Posted August 19, 2011 Share Posted August 19, 2011 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 More sharing options...
jeffman Posted August 19, 2011 Share Posted August 19, 2011 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 More sharing options...
ShadowMage Posted August 19, 2011 Share Posted August 19, 2011 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 More sharing options...
mwbarry Posted August 19, 2011 Author Share Posted August 19, 2011 OK in that case...Do you have any idea how to fix this problem without using a browser detection script? I've been trying to figure it out for nearly a week and haven't made any progress Link to comment Share on other sites More sharing options...
thescientist Posted August 19, 2011 Share Posted August 19, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.