Summary | Source files | Configuration | Examples | References


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.


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>

In order to restore the default styling, visit the styleswitch directory with supplied layout parameter '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 ]

Tillbaka till föregående sida

Lämna ett meddelande

Ditt namn:

Din epost-adress: (obligatorisk)


Generated by ::emailform::

Senast modifierad Saturday 02 Jul 2011
Denna sajt är XHTML 1.0 Strict