Re: A "Wanna Be" CSS programmer

by "Lisa Bradshaw" <zibbler(at)mediaone.net>

 Date:  Wed, 6 Feb 2002 14:26:21 -0500
 To:  "Hwg Style" <hwg-style(at)hwg.org>,
"Kevin W. Bishop" <bishopk(at)rpi.edu>
 References:  rpi
  todo: View Thread, Original
Here's an example of a browser sniffer that serves up different style sheets
dependeing on browser type and version. This is what I use for my sites:

<.SCRIPT language="JavaScript">
<.!--
var browserName=navigator.appName;
var browserVer=parseInt(navigator.appVersion);
if ((browserName=="Netscape" && browserVer>=6) || (browserName=="Microsoft
Internet Explorer" && browserVer>=4))
  version="n3";
else
  version="n2";

if (version=="n3")
  document.write("<link rel='stylesheet' type='text/css'
href='styles.css'>");
else
  document.write("<link rel='stylesheet' type='text/css'
href='styles_nn.css'>");
//-->
<./SCRIPT>

If you're going to copy and paste this for use, make sure you take out the
periods I put in the script tags and comment tag or it won't work. Also,
make sure you change the name of the style sheets in the document.write
section and name them whatever your stylesheets are named.

HTH,
Lisa


----- Original Message -----
From: "Kevin W. Bishop" <bishopk(at)rpi.edu>
To: "Hwg Style" <hwg-style(at)hwg.org>
Sent: Wednesday, February 06, 2002 1:35 PM
Subject: Re: A "Wanna Be" CSS programmer


>
> Among other things, we sniff for browser type/version and then serve the
> appropriate style sheet (and sometimes an alternate HTML file as well).
>
> You could also take advantage of, for instance, Netscape Navigator 4.x's
> weaknesses by referencing a style sheet in a way it doesn't understand,
and
> then in a way it does that is given lesser importance by the other
browsers.
>
> Specifically, NN4.x doesn't understand the @import ("cssfile.css");
> declaration ...
> For more information, see:
> http://www.alistapart.com/stories/tohell/
> http://www.alistapart.com/stories/journey/
>
> And, of course, glish.com is a good resource too.
>
> Good luck!
> -kb
>
>
> At 12:46 PM 2/6/2002 -0500, you wrote:
> >Dear Esteemed CSS Programmers,
> >
> >I returned to my international school armed with two books about
cascading
> >style sheets. I have read them and I am ready to go. However, I am quite
> >mystified by one main issue...the lack of CSS implementation by "older"
> >browsers (ie, Netscape 4 and IE 5).
> >
> >It seems to me that many HTML professionals are using CSS. Can someone
> >explain to me...on list or off...how you can develop style sheets of any
> >sophistication knowing that your site visitors may very well be using
these
> >"older" browsers?
> >
> >Thanks in advance for your assistance.
> >
> >
> >
> >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >Jennifer Peterson
> >Academia Cotopaxi, American International School
> >Quito, Ecuador
> >jpeterson(at)cotopaxi.k12.ec
> >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> _________________________________________
> Kevin W. Bishop
> Communication & Collaboration Technologies
> Rensselaer Polytechnic Institute
> <bishopk(at)rpi.edu> | <http://www.rpi.edu/rpinfo/>
>
>

HWG hwg-style mailing list archives, maintained by Webmasters @ IWA