Navigation Menu

What's New?
Alphabetical Listing
Site Contents


Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Become a Partner

Internet.commerce

Be a Commerce Partner














Internet.com

IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Developer Channel

FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

Great Sites

DocJavaScript.com
dhtml.com
The Freebie Directory
TheFreeSite.com

Browse Doc JS's Tips!


Hiermenus Central


Promotions

Free Announcements


Social Bookmark

General

Let your visitors change the style sheet on your Web site. This script will let your visitors choose between five style sheets, which you can create yourself or use the ones included.


Choose your style!

Style 1
Style 2
Style 3
Style 4
Style 5

Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: changeStyle.js


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


Other

Download the images using the URL below:

User Comments

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

8. From: Matt Strippelhoff
CSS >> change style >> problem with directories
04/03/2008 16:03:03

Great code, with one exception. The cookie seems to apply only to pages within the directory where the user selected a style sheet. When they browse the site, and view pages within a different directory, the default style sheet is used. Anyone have a suggestions as to how to alter the code to overcome this limitation?

6. From: Sean Ayotte
Change-Style - multiple pages
01/09/2008 13:02:52

I successfully used your code to create a user-defined css home page (with multiple external css files), but I wanted to know what I need to use in the headers of the pages to follow to keep this selection active?
(http://javascript.internet.com/css/change-style.html)

Thanks,
S

7. From: Lee Underwood (Admin)
01/29/2008 12:45:17

Sean, you would need something a bit different.

5. From: Grego
05/08/2007 13:19:05

I'm new at js, after following the directions carefully, the script only managed to put radio buttons and the list of style sheets in my Safari browser.

Any suggestions before I drag it into the trash?


4. From: jeff
04/24/2007 20:44:07

Great example. Thanks!

3. From: Rick
03/08/2007 16:20:11

For some reason the cookie in FireFox or Opera has an undefined value. As a result no style is applied.

2. From: 3R
01/10/2007 09:05:54

Most likely you either block document.write from your popup blocker, or you did not implement the script that well.

1. From: Ahmed
11/24/2006 18:00:24

When i use the code "document.write()" in my web page it get me in new white page why? thx :)


Do you write JavaScripts?
If you do, why not submit them to us?
We'll give you credit and a link back to your Web site.