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

Setting Colors

Another popular use of the document object’s properties is to set the colors in the page interactively, using the fgColor, bgColor, linkColor, alinkColor, and vlinkColor properties. Here’s an example that puts all five of these properties to use, where I’m using colors predefined in both the Netscape Navigator and the Internet Explorer:

(Listing 09-02.html on the web site)

<HTML> 
    <HEAD> 
        <TITLE>Setting Colors</TITLE> 
        <SCRIPT LANGUAGE="JavaScript"> 
            <!--
            function setColors()
					{
					document.fgColor = "cyan"
					document.bgColor = "lightyellow"
					document.linkColor = "blue"
					document.alinkColor = "red"
					document.vlinkColor = "orange"
					} 
            // --> 
        </SCRIPT> 
    </HEAD> 

    <BODY> 
        <H1>Setting Colors</H1> 
        Take a look at <A HREF="w3c.org">W3C</A> 
        <FORM> 
            <INPUT TYPE="button" VALUE="Set Colors" ONCLICK="setColors()"> 
        </FORM> 
    </BODY> 
</HTML> 

					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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