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

Example 7.5:
Returning Values--Broken Example


This is the same as the previous example, with the exception that we've removed the return sTypedText line from the function definition. Now the text from the Prompt box is not returned by the function. As you can see below, the text you typed is not inserted into the Web page:


These are the scripts we used. First, in the HEAD: <SCRIPT LANGUAGE="JavaScript"> <!-- function function1() { var sTypedText sTypedText = prompt("Type some text, then click on OK.", "") } //--> </SCRIPT> Later in the Web page: <SCRIPT LANGUAGE="JavaScript"> <!-- function function1() { var sTypedText sTypedText = prompt("Type some text in.", "") return sTypedText } //--> </SCRIPT>
Previous Example-|-Next Example-|-Return to Chapter Listing