[WEB4LIB] RE: Browser sniffing via javascript (was Draft home page not usable on my IE 6)
Thomas Dowling
tdowling at ohiolink.edu
Thu Jun 21 09:02:15 EDT 2001
> Lately I have seen a lot of 'browser sniffing' being done via javascript
> on web pages. It works like this:
> 1. javascript code is used to determine whether (for sake of
> argument) IE or Nav is being used.
> 2. separate stylesheets are employed (i.e. 1 for Nav, 1 for IE), and
> the appropriate stylesheet is invoked depending on the result of the
> browser sniff.
>
> I find I am uncomfortable with this method in principle, for what if the
> user has javascript turned off? Is there a better way to use 2
> stylesheets, each customized for a different browser, without having
> to rely on javascript? Or, is it simply better to use one stylesheet
for
> all browsers (I have noticed that the main difference between the 2
> stylesheets seems to be this - font sizes are expressed in 'pts' for
> Nav, and in '%' for IE).
First, let me concur with other posts saying that the better solution is
browser-independent markup in both HTML and CSS.
However, Netscape 4 is something of a special case, in that its support
for CSS is often not merely incomplete, but incorrect. There are times
when it needs to be protected from itself, and then most common way to do
this is to write one stylesheet that includes all the NS4-safe style
properties, and that imports whatever other styles you want from a second
stylesheet. NS4 does not support the "@import" statement, so it never
even sees properties from the second stylesheet:
Thomas Dowling
OhioLINK - Ohio Library and Information Network
tdowling at ohiolink.edu
More information about the Web4lib
mailing list