[an error occurred while processing this directive]
[url] rasterweb.net/raster/
[email] pete@rasterweb.net
[pgp key] public key

RasterWeb [More Info]
Home
About
Contact
Archives
Search
Mobile Edition
Kids
Misc
Rambles
Computers
Code

Code:
Code contains bits of text that are probably more interesting to computers than people...


[RasterWeb]

Lots of pages on this site will serve a style sheet that is appropriate to your browser. This requires browser detection and some sort of if/then mechanism. Luckily Apache's SSI fits the bill nicely. Separating the presentation via style sheets is a good thing we can all agree on, well, the browser makers still need to agree on it.

The below piece of SSI will serve a different style sheet for Netscape 4.x. If you've been writing html and using css for a while you know that MSIE 5.x for the Mac and Windows, and Mozilla/Netscape 6/things based on Gecko should all around render things pretty similarly while Netscape 4 is a boat anchor around our necks... This code can be extended in many ways, such as checking the OS used, but I've kept it simple for this example.If you're familiar with browser id strings, you'll know that "Mozilla 4" matches lots of browsers, but "Mozilla 4" and "compatible" should not match Netscape 4.x browsers...

Oh, you put this code in the head of the document, the same place you'd put the call to the stylesheet, since that's what will be served.


<!--#if expr="($HTTP_USER_AGENT = /Mozilla\/4/) && ($HTTP_USER_AGENT != /compatible/)" -->
   <link rel="stylesheet" type="text/css" href="/stylenetscape4.css">
<!--#else -->
   <link rel="stylesheet" type="text/css" href="/style.css">
<!--#endif -->



[top of page]

  Last Modified: 08.17.2000 by rasterboy