[thelist] http_user_agent

aardvark roselli at earthlink.net
Wed Mar 20 19:54:00 CST 2002


> From: Erik Mattheis <gozz at gozz.com>
[...]
> >using a server side script like php and outputting html/xhtml based
> >on http_user_agent a useful way of achieving this?
>
> If anyone and everyone is going to be able to use the site, someone is
> going to eventually see a cached version intended for a different
> browser.

absotively... proxy servers can cache that stuff... not to mention the HTTP
User Agent is less-than-ideal since you have to parse all the possibilites and
serve the appropriate CSS...

we all (almost) know better than to check for browser versions in our JS -- we
learned to do function checks... why wouldn't we do the same with CSS?

> Look at your user agents in your log files - I'm quite certain you
> don't have to worry about non-CSS browsers ... just about the only
> people that use them do so because they don't _want_ to see CSS, etc.

not the *only*... but do look at your log files... depending on the kind of site
you run, you may stray from average traffic by a bit...

> If you're going to do much more than text formatting with CSS, you're
> going to want/need to serve different stylesheets to different
> browsers, in which case you should document.write() to different
> external stylesheets based on the userAgent ... some people like to
> use @IMPORT.

ewww... that completely goes against the elegance of either function checking
or one-for-all creation...

first off, if it's a CSS layout, you're looking at similar support in the post-4.x
browsers...  the 4.x and earlier are generally non-CSS...

you could check on that...

the elegance of the @import protocol is that, while some feel it is a hack, it's
perfectly legal and allows you to ensure your margin/paddin/line-height won't
hose NN4.x...

overall, unless there's something *really* wonky, one linked CSS file and one
imported CSS file should handle 95%+ of your cases...

and let's not forget the number of users with JS turned off (like both N6 and
O6 on my machine) as well as those users in corporate environments where
JS is disabled or stripped for security...




More information about the thelist mailing list