Summary | Source files | Configuration | Examples | References
StyleSwitch
The StyleSwitch scripts address the problem of dynamically switching CSS styling of a web site, allowing a site visitor to alter the styling to whatever theme he/she prefers.
http://jonsson.eu/styleswitch/
The above combo box was generated by the following (X)HTML code:
<select name="csscollection" onchange="jumpMenu('parent',this,0)">
<option value="" selected="selected">Select theme …</option>
<option value="/styleswitch/?layout=jonssona">Bluebox</option>
<option value="/styleswitch/?layout=jonssonb">Wireframe</option>
<option value="/styleswitch/?layout=jonssonc">Chameleon</option>
<option value="/styleswitch/?layout=jonssond">Typographic</option>
<option value="/styleswitch/?layout=unstyled">Unstyled</option>
</select>
In order to restore the default styling, visit the styleswitch directory with supplied layout parameter 'jonssond':
http://jonsson.eu/styleswitch/?layout=jonssond
The scripts depend on cookies set at the client side, though if a visitor has disallowed the setting of cookies, the scripts simply ignores switching. The lifetime of the set cookie is in this case set to a relatively short time, being only 24 hours. Thus, anyone who revisits the site within 24 hours will see the last theme displayed while a revisit after more than 24 hours will result in the default theme being displayed again.
Current revision
Revision 1.0, as of 19/10/2007. Copyright © Fredrik Jonsson 2007, under GPL
Source files
styleswitch.php
[7 kB]
The entire PHP code for the dynamic style switching script,
containing all necessary routines in one single file.
[ download |
view source ]