home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Archived / Internet / jvscript116beta / JvScript / !JvScript / Resources / Scripts / Date+Time / 1 next >
Encoding:
Text File  |  1999-09-09  |  1.1 KB  |  48 lines

  1. #newformat
  2. # © Geoff Youngs, 1999
  3. _title:Clock
  4. _description:Display a digital clock on the page
  5. _insert-in:inhead
  6. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  7. <!--
  8. var timerID = null;
  9. var timerRunning = false;
  10. var id,pause=0,position=0;
  11. function stopclock ()
  12. {        
  13. if(timerRunning)
  14.                 clearTimeout(timerID);      
  15. timerRunning = false;
  16. }
  17. function showtime () 
  18. {        
  19. var now = new Date();
  20. var hours = now.getHours();      
  21. var minutes = now.getMinutes();
  22. var seconds = now.getSeconds();
  23. var timeValue = "" + ((hours >12) ? hours -12 :hours)
  24. timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  25. timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  26. timeValue += (hours >= 12) ? " P.M." : " A.M."
  27. document.clock.face.value = timeValue;
  28. timerID = setTimeout("showtime()",1000);
  29. timerRunning = true;
  30. }
  31. function startclock ()
  32. {
  33. stopclock();     
  34. showtime();
  35. }
  36. // --End Hiding Here -->
  37. </SCRIPT>
  38. _end-insert:
  39.  
  40. _insert-in:bodytag
  41. onLoad="startclock()"
  42. _end-insert:
  43.  
  44. _insert-in:inbody
  45. <FORM NAME="clock" onSubmit="0">
  46. <INPUT TYPE="text" NAME="face" SIZE=13 VALUE="">
  47. </FORM>
  48. _end-insert: