首页  编辑  

一个可以开关的时钟

Tags: /计算机文档/网页制作/   Date Created:

<script language="JavaScript">    

       var enabled = 0;    

function TOfunc() {      

       TO = window.setTimeout( "TOfunc()", 1000

);      

       var today = new Date();      

       document.clock.disp.value =

today.toLocaleString();

       }

</script>

<form name="clock">

<input type="text" name="disp" value="" size=20

onFocus="this.blur()" >

<br>

<input type="radio" name="rad" value="OFF"

checked  

onClick="

 if( enabled==1 )

   {

    document.clock.disp.value='';

    clearTimeout( TO );

    enabled = 0;

    }

  ">

<input type="radio" name="rad" value="on"  

onClick="

    if( enabled == 0 ) {

       var TO = setTimeout( 'TOfunc()', 1000 );

       enabled = 1;     }" > 开

</form>