Quick Search:
Oracle PL/SQL Code Library
Find Or Post Oracle Jobs
Oracle Discussion & Chat
 JavaScript: Easy Style Sheet Switcher Jump to:  
Category: >> JavaScript >> Easy Style Sheet Switcher Bookmark and Share

<< lastnext >>

Snippet Name: Easy Style Sheet Switcher

Description: A few points of interest:

* The HREF links use JavaScript to set a browser cookie named "style".

* Since we are only setting one cookie and it's name is "style", we can read its value using "document.cookie.charAt(6)".

* If no cookie is set, "StyleFile" will evaluate to "style.css".

* The files names of the style sheets need to be "style.css", "style2.css", "style3.css", "style4.css", and so on.

Also see:
» CSS Colornames to RGB values

Comment: (none)

Highlight Mode: JAVASCRIPT
Last Modified: March 15th, 2009

<html><head><title>Style Switcher</title>
VAR StyleFile = "style" + document.cookie.charAt(6) + ".css";
document.writeln('<link rel="stylesheet" type="text/css" href="' + StyleFile + '">');
</head><body><h2>Easy Style Sheet Switcher</h2><br>
<a href="javascript: document.cookie='style='; window.location.reload();">Style 1</a> |
<a href="javascript: document.cookie='style=2'; window.location.reload();">Style 2</a> |
<a href="javascript: document.cookie='style=3'; window.location.reload();">Style 3</a>

Oracle Magazine
and Oracle White Papers

SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 35 users online    © 2009 psoug.org

Forgot your password?