Home
JavaScript
  Today's Date
  Dropdown Menu
  Mouse Over
  Status Bar
  Status Runner
  Background Color
  Script Tester
  Mini-Windows
  Cookies
  Expiration
Java Applets
Available CGI
META Tags
Server Elements

Changing Background Color

   
 

Javascript makes it possible to change background color of a document dynamically. This means that you can have terrible visual effects like the one you just saw. Actually, I had planned to make a smooth shade out sort of thing but somehow, it got like this.

Your turn now. Select your favorite color from here :

The command for changing the background color is
document.bgColor = "rrggbb"
where "rrggbb" is a string specifying the red, green and blue components of the color in hexadecimal. The code for the above example is given below.

    

If you specify a background image, then background color will have no effect. So, on pages like these, it's better not to specify a background image.