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> 

You can see the results in Figure 9.2 (in glorious black and white).

Figure 9.2. Setting colors in the Netscape Navigator.

graphics/09fig02.gif



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net