(page requirements)

Let your visitors choose colors for your pages

Maybe you enjoy using bright pink backgrounds for your web pages. Are you sure your visitors can appreciate it? Why not let them choose the background color, or any other document color, for your pages? Checkout the following example:
The basic idea here is to use JavaScript to change the background color using the following command ("#FFFFFF" being the hex representation of the color we want):
document.bgColor = '#FFFFFF';
Listing #1 : JavaScript code. Download setcolor (0.16 KB).
If you like the idea, you can have what you see in the above example simply by inserting the following tags in to your page:
<form name="test" method="post">

 <input type="button"
     OnClick="document.bgColor = '#FFFFFF';"

 <input type="button"
     OnClick="document.bgColor = '#00FFFF';"

 <input type="button"
     OnClick="document.bgColor = '#FF00FF';"

 <input type="button"
     OnClick="document.bgColor = '#FFFF00';"

Listing #2 : HTML code. Download setbkclr (0.28 KB).
To change the color of the text instead, replace bgColor with fgColor. Using linkColor will make the above script change the color of the links and vlinkColor will change the color of the visited links.
You can find the hex representation of all web safe colors in this web page color table.
Applicable Keywords : HTML, Internet Explorer, Explorer 3.x, Explorer 4.x, Explorer 5.x, Internet, JavaScript, JavaScript 1.0, JavaScript 1.1, JavaScript 1.2, Netscape Navigator, Navigator 2.x, Navigator 3.x, Communicator 4.x, Netscape 6.x, World Wide Web
Copyright © 2009 Chami.com. All Rights Reserved. | Advertise | Created in HTML Kit editor