This JavaScript example will display a JavaScript clock with an optional on/off switch.
var enabled = 0; function TOfunc() { TO = window.setTimeout( "TOfunc()", 1000 ); var today = new Date(); document.forms[0].elements[0].value = today.toString(); }
function Stopfunc() { clearTimeout(TO); var enabled = 0; }
OFF ON
JavaScript Source Code 3000: Clocks: On/Off Clock Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!
<!-- TWO STEPS TO INSTALL ON/OFF CLOCK:
1. Add the onload event handler into the BODY tag of your page 2. Put the designated code into the BODY of your HTML document -->
<!-- STEP ONE: Add the onload event handler into the BODY tag -->
<BODY onload="TOfunc()">
<!-- STEP TWO: Put this code into the BODY of your HTML document -->
<SCRIPT LANGUAGE="JavaScript">
<! > <! >
var enabled = 0; function TOfunc() { TO = window.setTimeout( "TOfunc()", 1000 ); var today = new Date(); document.forms[0].elements[0].value = today.toString(); } </SCRIPT>