...

View Full Version : Changing stylesheets dynamically



Grant Palin
11-26-2002, 01:21 AM
I've seen it done, but I don't know HOW it was done. I'd like to add the option to change stylessheets on my site, so the user can click a link to change the current stylesheet. I can do the stylesheet itself, but HOW would I change it? Javascipt?

x_goose_x
11-26-2002, 04:29 AM
Tested in IE6/Moz1.2b



<html>

<head>
<LINK id="stylecss" REL=StyleSheet HREF="mystyle.css" TYPE="text/css" MEDIA=screen>
</head>

<body>
This is my text <a href="javascript: document.getElementById('stylecss').setAttribute('href','mystyle2.css');">LINK</a>
</body>

</html>

Grant Palin
11-26-2002, 04:39 AM
Would that apply to the whole site, or just that one page? Is there a way to make that style selection apply to the whole site until the viewer leaves or changes the style back?

jtr
11-26-2002, 06:00 AM
Maybe something like this.

http://www.web-sn.com/scrpts/skinner/

joh6nn
11-26-2002, 08:35 AM
http://www.alistapart.com/stories/n4switch/

BrainJar
11-26-2002, 04:28 PM
Here's how I did it on my site, using ASP on the server:

http://www.brainjar.com/asp/schemes/

Whether you do it client-side or server-side, you'll probably want to save the user's selection using a cookie so it can be applied to all pages on your site.

MCookie
11-26-2002, 04:42 PM
Another one from ALA:

http://www.alistapart.com/stories/alternate/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum