Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alternate style sheets

Status
Not open for further replies.

actionpants

Technical User
Nov 17, 2002
1
US
Hi, i've been working on a site which is 100% valid, error- free XHTML 1.0 transitional when checked against the WC3 validator. the pages will not display correctly, however, in netscape 7 and opera 6.05....its really frustrating! My intention was to have the pages / site look the same in all the current browsers (ie6, ns7 etc)....i'm linking to an external .css and right now i'm wondering if there is a way i can specify an alternate style sheet, based upon what browser the user is using (basically anything other than IE6, as that is the only browser properly displaying the pages). Is this possible? i thought i read about how to do this somewhere but can't remember where...any suggestions?
 
>> its really frustrating!

No way! LOL

If you have any server side processing it is simple to do there. You just place different style sheet link elements into the pages as you build them.

With client side only you can effectively do the same with script and then alter the navigation path to point to different pages/directories that contain the target css links.

Good luck
-pete
 
It's actually easy to do using a little javascript.

Here's an example of such a script. It's pretty old and so is a little out of date version wise. But the principle is sound.


if ((navigator.appVersion.indexOf("Mac") != -1)) {
if ((navigator.appName.indexOf("Netscape") != -1)) {
document.writeln(&quot;<link rel=\&quot;stylesheet\&quot; href=stylesheet_NS.css&quot; type=\&quot;text/css\&quot;>&quot;);
} else {
document.writeln(&quot;<link rel=\&quot;stylesheet\&quot; href=stylesheetMac.css&quot; type=\&quot;text/css\&quot;>&quot;);
}
} else {
document.writeln(&quot;<link rel=\&quot;stylesheet\&quot; href=stylesheetWin.css&quot; type=\&quot;text/css\&quot;>&quot;);
}


simple as that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top