• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Changing Document Colors

The Document object's property list includes several items that change the default document colors, and you saw in Table 22.1 that these properties are the JavaScript equivalent of the <body> tag's color attributes. To set these colors, you have two choices:

  • Use one of the predefined color names supported by Internet Explorer and Netscape. This so-called X11 color set consists of 139 plain-English color names, some of which are shown in Figure 22.1. See 22.X.htm on my site for the complete list. Here's an example:

    Figure 22.1. The X11 color set consists of 140 English names for colors.

    document.bgColor = "yellow"
    
  • Use an RGB string of the following form:

    "#RRGGBB"
    

    Here, RR is a two-digit hexadecimal value that specifies the red component of the color; GG is a two-digit hexadecimal value that specifies the green component of the color; and BB is a two-digit hexadecimal value that specifies the blue component of the color. Here's an example:

    document.fgColor = "#00FF33"
    

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint