Previous Example-|-Next Example-|-Return to Chapter Listing

Example 15.3:
Referring to Frames

Note that we had to change the script in this example. Originally we used a function named reset(), but as reset is a reserved word in JavaScript 1.2 this script won't work in Netscape Navigator 4. Therefore we renamed the function to resetColors(). Click on the buttons to change the colors:


These are the scripts we used. First, this in the HEAD: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- function resetColors() { window.document.bgColor="white" top.frames[1].document.bgColor="white" top.frames[2].document.bgColor="white" top.frames[3].document.bgColor="white" } //--> </SCRIPT> Then these buttons: <FORM> <INPUT TYPE="button" VALUE="Change first frame to Orange" onclick="parent.frames[0].document.bgColor='orange'"><P> <INPUT TYPE="button" VALUE="Change frame2 to Red" onclick="parent.frames[1].document.bgColor='red'"><P> <INPUT TYPE="button" VALUE="Change frame3 to Green" onclick="parent.frame3.document.bgColor='green'"><P> <INPUT TYPE="button" VALUE="Change frame4 to Blue" onclick="top.frames[3].document.bgColor='blue'"><P> <INPUT TYPE="button" VALUE="Reset Colors" onclick="resetColors()"> </FORM>
Previous Example-|-Next Example-|-Return to Chapter Listing