View Full Version : Different external css for NS4

06-14-2002, 08:58 PM
This is prolly a JS question, though here goes anyway:

How do I detect NS4 and make it use a different external stylesheet? is it just something like:

<link href="main.css" rel="styleSheet" type="text/css">
if (document.layers)
document.location = "ns4.css"

or similar? I hate accounting for NS4, though it won't support css background effects like no-repeat etc. If I can just shunt it to a different stylesheet all will be right with the world :). I can't get this to work for some reason. Do I need an 'else' statement?

06-14-2002, 09:15 PM
Detection can become a waste of time in certain scenarios, especially when there are simpler methods...

the @IMPORT option will make this easier for you, since NS4 does not recognize it, but virtually all other browsers do, so browsers other than NS4 will pull in the second stylesheet with the more advanced stuff, while NS4 will only see a slimmed down stylesheet (and only one).

<link rel="stylesheet" type="text/css" href="/path/to.css">
<style type="text/css">
@import url(/path/toadv.css);

06-14-2002, 10:30 PM
That is quite a bit easier, isn't it? :) Thanks Feyd.

06-15-2002, 08:16 PM
Okay, I'm getting curious now as to what other uses the @import url statement has. Could you please point me to a reference for it? I bet it's good for a lot of things.


Nevermind. Went through the W3 CSS reference (http://www.w3.org/TR/REC-CSS1.html) and apparently this is all it does. Is this yet another case of W3C finding different statements to do things browsers already do? Regardless, glad it works in this instance. :)