document.bgColor

JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax

document.bgColor

Description

The bgColor property specifies the background color of HTML document. The color is expressed as a string in hexadecimal digits or as one of the JavaScript standard color names. The hexadecimal form is made up of six digits that follow the pattern "RRGGBB." The color of the background can also be set with bgcolor attribute of the <body> tag.

Example

Listing 7.57 changes the document's background color based on which button is chosen.

Listing 7.57 Modifying the Document bgColor Property
 <html> <form> <input type="button" value="Yellow" name="Yellow" onClick="changeBG('yellow')"> <input type="button" value="Green" name="Green" onClick="changeBG('green')"> ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.