My approach is to write valid, standards-compliant HTML and CSS which works fully on modern browsers but will still be legible (if not necessarily pretty) on older browsers. Look at your access logs to see how many people are using older browsers, are there enough to make it worth supporting them?
If you DO decide to sniff out the browser version, do it in the server - PHP, ASP, Perl (via SSI), whatever - rather than Javascript. There are probably as many visitors (if not more) who surf with Javascript switched off as surf with, say NS4.7.
Server side detection would be great, but I'm afraid it isn't something I know.
I think you over estimate the number of people surfing with javascript switch off. Since most web surfers are computer simpletons, they wouldn't know how nor think to turn off javascript.
From our site statistics over the last week (since we started logging), 95%+ uses IE5 or later (or compatible, e.g. Mozilla or Netscape 7).
So if you code for IE 5 compatibility you're pretty safe.
If you code for IE, Microsoft has put plenty of bugs and "features" that sabotages standard compliant efforts. This would make your pages less compatible with some of the most standard compliant browsers out there (Gecko Based such as Mozilla or Phoenix).
People with truly standard compliant browsers would come less often to your site. If too many sites code only for IE and it's propritary standards many will be forced to use Internet Explorer. Microsoft will love you because that means they will make even more money with their monopoly. I won't love you though! ;-)
(I don't even do as I preach, my site doesn't yet validate but I'm in the process of redoing it).
So long as things validate you should feel confident that future browsers can render it properly. It is a good idea to test it in browser you believe are going to want to see your site.
I personally and out of principle never support NS4 because of it's old proprietary implementations. I only worry about 5.x and above browsers as that is generally my audience.
In reality IE is probably the least standards compliant browser going, many people go for NS bashing but the reason for a lot of problems are using the proprietary attributes in IE and expecting it to work in a strict standards compliant browser.
the only way to go is write standards compliant HTML and CSS and avoid the proprietary 'features' in ALL browsers
As for NS4 (and IE4) users at sometime they have to realise the world moves on.
Chris.
Indifference will be the downfall of mankind, but who cares?
Except for occasional bits of weirdness, chances are if you're encountering something that requires you make such a decision, there is probably a third option: avoid that functionality.
If you design your pages and your site from the beginning to pass the w3c tests and to run pleasantly under the basic browser-set (IE, netscap, mozilla), then you'll have a web page/site that will be enjoyed by pretty much everybody who visits it.
For some things, there are browser-specific pecadilloes. Consider it a challenge to work around that crap. Yes, sometimes this can be a pain, but the only way to win the browser-functionality contest is to simply not play. Find a solution that doesn't care which browser runs.
I ran across a thing in a script: I did a JavaScript split command in a string on a character. IE and Netscape handled the results differently if the character didn't exist in the string (which could happen). I almost, in frustration, wrote a what-browser's-running function. But then I realized that was the wrong path. Instead, I assigned the value of the split to a variable and determined the type of the variable. In one case, it was Null, in another case, it was not Null, but it was empty. Aha! So, I used that as my check. Now, instead of checking some kind of name-of-browser string, I simply check for the actual thing that is relevent: how does this browser handle that weird little split. Voila. No checking for browser type.
In short, write for the world, not for Microsoft or Netscape or Mozilla. If you must add a decision-tree in your code, do so based on the actual thing you're checking, not along browser titles.
Cheers,
Edward
"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
, about 9% of users surf with javascript switched off, compared to 2% using version 4 browsers. I know who I'd concentrate my efforts on - it seems crazy to use javascript to serve a special style sheet to users of some crummy old browser, but serve no style sheet at all to (paranoid) users of modern browsers who disable scripting.
As to how to detect browsers on the server side, you do it the same way as through JavaScript - by looking at the environment variables. Take a look at
Having said that, I agree with Edward that it's better, if you must sniff something, to sniff out capabilities rather than browser flavours - "can you do this" rather than "are you browser xyz (and thus able to do this)". Better still to avoid browser-specific gew-gaws and concentrate on the content of your site!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.