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

Example 6.18:
A JavaScript 1.2 do while Loop


[This example works with Netscape Navigator 4. It will not work with Netscape Navigator 3 or Internet Explorer 3.]

This example uses the new JavaScript 1.2 do while loop:


In the HEAD we have this script: <script language="JAVASCRIPT"> <!-- function function1() { var sWord ="" do { sWord = prompt("Input the word \'Aardvark\' in order to stop the loop","") } while (sWord != "Aardvark") alert("The loop has finished") } //--> </script> In the BODY of the page we have this button: <form> <input type="button" value=" Button A " onclick="function1()"> </form>
Previous Example-|-Next Example-|-Return to Chapter Listing