JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Document.bgColor Property

Name

Document.bgColor Property---the document background color

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

document.bgColor

Description

bgColor is a string property that specifies the background color of document.

The document text color can be set through the BGCOLOR attribute in the <BODY> HTML tag, and the bgColor property will contain the specified value. The background color may also be specified by assigning a value to bgColor directly. Unlike the other color properties, bgColor can be set at any time. Unfortunately, in Navigator 2.0, setting bgColor is buggy.

Colors are specified either as one of the standard color names recognized by JavaScript, or as red, green, and blue color values, expressed as a string of six hexadecimal digits in the form "RRGGBB".

Usage

When setting one color property for a Document, you should probably set the other color properties to match. Be careful when specifying color values; it is far easier to end up with a garish web page than it is to choose a palette of harmonious colors. In general, the default colors are a safe choice, and may also reflect the end user's color preferences.

Note that the background of a document may also be set to an image with the BACKGROUND attribute of the HTML <BODY> tag.

See Also

"Document", "Document.alinkColor", "Document.fgColor", "Document.linkColor", "Document.vlinkColor", Appendix G, JavaScript and HTML Color Names and Values


Previous Home Next
Document.applets[] Book Index Document.clear()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
Hosted by uCoz