Availability: |
| ||||||||
Property/method value type: | color value | ||||||||
JavaScript syntax: | - | myDocument.bgColor | |||||||
- | myDocument.bgColor = aColorValue | ||||||||
HTML syntax: | <BODY BGCOLOR="aColorValue"> | ||||||||
Argument list: | aColorValue | A hex color value or color name |
This corresponds to the BGCOLOR="..." HTML tag attribute on the <BODY> tag.
You can modify this value at any time, the results 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.
The background can be colored independently of whether an image is loaded into the background of an object. 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.
On the Unix platform, the Netscape browser versions 2 and 3 exhibit a bug when changing the background color. If you attempt to do this, the page content disappears until something causes the window to be redrawn. If you are using X-Windows, you may be able to alleviate this by changing the damage control policy; however, you would likely need to change it to a slower performing damage control model and that change would apply to all applications in the session. Alternatively, detect the platform and avoid the background color change.
Prev | Home | Next |
Document.background | Up | Document.body |
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. |