View Full Version : Changing stylesheets dynamically

Grant Palin
11-26-2002, 12: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?

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


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

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


Grant Palin
11-26-2002, 03: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?

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


11-26-2002, 07:35 AM

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


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.

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


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum