The bgColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the BGCOLOR attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu.
You can set the bgColor property at any time.
If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072".
例子
The following example sets the color of the document background to aqua using a string literal:
document.bgColor="aqua"
The following example sets the color of the document background to aqua using a hexadecimal triplet:
passwordName is either the value of the NAME attribute of a password object or an element in the elements array. selectName is either the value of the NAME attribute of a select object or an element in the elements array. textName is either the value of the NAME attribute of a text object or an element in the elements array. textareaName is either the value of the NAME attribute of a textarea object or an element in the elements array.
NAME="buttonName" specifies the name of the button object. You can access this value using the name property. VALUE="buttonText" specifies the label to display on the button face. You can access this value using the value property.
buttonName is the value of the NAME attribute of a button object. formName is either the value of the NAME attribute of a form object or an element in the forms array. index is an integer representing a button object on a form. propertyName is one of the properties listed below. methodName is one of the methods listed below.
A button object is a form element and must be defined within a <FORM> tag.
The button object is a custom button that you can use to perform an action you define. The button executes the script specified by its onClick event handler.
The following example creates a button named calcButton. The text "Calculate" is displayed on the face of the button. When the button is clicked, the function calcFunction() is called.