This corresponds to the BGCOLOR="..." HTML tag attribute on the <BODY> tag.
You can modify this value at any time, the result of which will be to change the background color of the page.
Now that the style control facilities are more sophisticated, this tag attribute is likely to fall into disuse. On the other hand it does work consistently on both MSIE and Netscape where style sheet controls do not. Later, a DOM standardized approach to style handling will provide a cross platform way to access style information from JavaScript. DOM level 2 introduces a first attempt at standardizing this area.
The background can be colored whether an image is loaded into the background of a document or not. In fact, it may be advisable to set the background color to something similar to the average color of the background image in case the image takes a long time to load or the browser is unable to display a background image.
The background color for the document that is defined in the <BODY> tag is also reflected in the bgColor property of the document object, although that is now deprecated as of DOM level 1.
See also: | Color names, Color value, Document.bgColor, Document.linkColor, HTML object |
Prev | Home | Next |
BODY.background | Up | BODY.bgProperties |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |