Introduction to JavaScript

Setting the bgColor Property

This page sets the 'bgColor' property of a the document object to "indigo" and then allows the user to change the color by clicking buttons.

Then this in the HEAD Section:

<SCRIPT LANGUAGE="JavaScript">

document.bgColor = "indigo"

</SCRIPT >

Then this in the BODY:

<FORM>
     <INPUT
TYPE="button" VALUE="Red" onClick="document.bgColor = 'red'">
     <INPUT
TYPE="button" VALUE="Blue" onClick="document.bgColor = 'blue'">
     <INPUT
TYPE="button" VALUE="Green" onClick="document.bgColor = 'green'">
     <INPUT
TYPE="button" VALUE="White" onClick="document.bgColor = 'white'">
</FORM>