Style Switcher | JavaScriptSource

Style Switcher

Micah Atwell Jan 10, 2007


Provide your visitors with a method for toggling the text and background colors of your page or certain sections within it. Though simple, this script has a lot of potential and could be greatly expanded. Heavily commented.

»» Change foreground/background colors

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues.

Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Defacto lingo est igpay atinlay.


In the body of the Web page, be sure to enclose the text you want to allowed changed with the following division tags:

<div class="textDefault"></div>

Source Code

Paste this source code into the designated areas.

External file

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


Paste this code into your external CSS file or in the <style> section within the HEAD section of your HTML document.


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


Paste this code into the BODY section of your HTML document

Leave a Response


good website

rachid Jan 13, 2007

The HREF attribute for your toggle link should be set to the filename of the document in which this code is used (in case your visitor does not have Javascript enabled).

Micah Jan 10, 2007