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

Example 7.2:
A Function Defined in the Wrong Place


Yes, we know you saw an error message saying "function1 is not defined" when you opened this page...
That's because the function is
called in a script before the script in which function1() is defined.

These are the scripts we used: <SCRIPT LANGUAGE="JavaScript"> <!-- function1() //--> </SCRIPT> <SCRIPT LANGUAGE="JavaScript"> <!-- function function1() { alert("This is function1 running.") } //--> </SCRIPT> </HEAD> <BODY> <BR>
Previous Example-|-Next Example-|-Return to Chapter Listing