home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 1999 July / www_07_1999.iso / prez / amiga / KidHTML1_25.lha / KidHTML1.25 / Script / timeonpage.js < prev    next >
Text File  |  1998-08-25  |  1KB  |  48 lines

  1. <!-- THREE STEPS TO INSTALL TIME ON PAGE (CLOCK):
  2.  
  3.    1.  Paste the coding into the HEAD of your HTML document
  4.    2.  Copy the onLoad event handler into the BODY tag
  5.    3.  Add the last code into the BODY of your HTML document  -->
  6.  
  7. <!-- STEP ONE: Copy this code into the HEAD of your HTML document  -->
  8.  
  9. <HEAD>
  10.  
  11. <SCRIPT LANGUAGE="JavaScript">
  12.  
  13. <!-- This script and many more are available online from -->
  14. <!-- The JavaScript Source!! http://javascriptsource.com -->
  15.  
  16. <!-- Begin
  17. startday = new Date();
  18. clockStart = startday.getTime();
  19. function initStopwatch() { 
  20. var myTime = new Date(); 
  21. return((myTime.getTime() - clockStart)/1000); 
  22. }
  23. function getSecs() { 
  24. var tSecs = Math.round(initStopwatch()); 
  25. var iSecs = tSecs % 60;
  26. var iMins = Math.round((tSecs-30)/60);   
  27. var sSecs ="" + ((iSecs > 9) ? iSecs : "0" + iSecs);
  28. var sMins ="" + ((iMins > 9) ? iMins : "0" + iMins);
  29. document.forms[0].timespent.value = sMins+":"+sSecs;
  30. window.setTimeout('getSecs()',1000); 
  31. }
  32. // End -->
  33. </script>
  34.  
  35. <!-- STEP TWO: Add this onLoad event handler into the BODY tag  -->
  36.  
  37. <BODY onLoad="window.setTimeout('getSecs()',1)">
  38.  
  39. <!-- STEP THREE: Put this code into the BODY of your HTML document  -->
  40.  
  41. <CENTER>
  42. <FORM>
  43. <input size=5 name=timespent>
  44. </FORM>
  45. </CENTER>
  46.  
  47. <!-- Script Size:  1.29 KB  -->
  48.