Document.bgColor (Property)

The background color of the document.

Availability:

DOM level - 0
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
Deprecated
Property/method value type:color value
JavaScript syntax:-myDocument.bgColor
-myDocument.bgColor = aColorValue
HTML syntax:<BODY BGCOLOR="aColorValue">
Argument list:aColorValueA 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.

Warnings:

See also:BODY object, BODY.aLink, BODY.bgColor, BODY.link, BODY.text, BODY.vLink, Color names, Color value, Document object, Document.alinkColor, Document.fgColor, Document.linkColor, Document.vlinkColor, style.backgroundColor