advertisement -- please support sponsors

changing the document's background color

The document object has several color properties that can be set; one of them is the bgColor object.

The bgColor object can be be set even after the document has loaded. This is done by assigning it a six digit hexidecimal RGB string value or one of the predefined JavaScript color values.

For example, the following HTML/JavaScript code will create two form buttons in the document. When pressed, the first button will immediately change the document background color to black. The second will change it to yellow:

<form> <input type=button value="change background to black" onClick="document.bgColor='black';" > <input type=button value="change background to yellow" onClick="document.bgColor='ffff00';" > </form>

Note that although the document object has several other color properties pertaining to the foreground text and hyperlink colors, changes made to these properties after the document has been loaded will not be reflected in the browser window. That's a disappointment, but something we have to live with for a while.

Charlton Rose