--------------------------------------------------- | Date: 2002-09-14 18:39:45 | | Filename: while.js | | Author: mind@metalshell.com | | | | http://www.metalshell.com/ | --------------------------------------------------- <!-- while.js - mind (mind@metalshell.com) --> <!-- this shows a basic example of how to use --> <!-- the while statement in javascripting --> <!-- http://www.metalshell.com --> <!-- put this code into the <head> section of your html document. --> <!-- start our javascript --> <script language=JavaScript> // define i as a integer of 0 var i = 0; // define max as a integer of 10 var max = 10; // define message a string of: This is.. var message = "This is our message"; // create our function function printText() { // while (condition) { statements; } // start our while loop while (i < max) { // increase i with each loop i++; // print our message document.write('<font>' + message + '</font><br>'); } } // never ending while loop: while (1) { statements; } // end of our javascript </script> <!-- place this code anywhere on your html document (example) --> <!-- align our link below --> <div align=center> <!-- make a link that points to our js function printText() --> <a href="javascript: printText();">Click Here!</a> </div>