第一步:把如下代码加入<body>区域中 <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var ms = 0; var state = 0; function startstop() { if (state == 0) { state = 1; then = new Date(); then.setTime(then.getTime() - ms); } else { state = 0; now = new Date(); ms = now.getTime() - then.getTime(); document.stpw.time.value = ms; } } function swreset() { state = 0; ms = 0; document.stpw.time.value = ms; } function display() { setTimeout("display();", 50); if (state == 1) {now = new Date(); ms = now.getTime() - then.getTime(); document.stpw.time.value = ms; } } // End --> </SCRIPT> <FORM NAME="stpw"> 本例<a href=http://www.letgo.com.cn>时间特效</a>可以准确到百分之一秒<br><br> <b>计时开始:</b> <INPUT TYPE="text" Name="time"><br> <INPUT TYPE="BUTTON" Name="ssbutton" VALUE="开始/停止" onClick="startstop()"> <INPUT TYPE="BUTTON" NAME="reset" VALUE="重置" onClick="swreset()"> </FORM>
第二步:把<body>区域中的内容为 <body bgColor=#fef4d9 onLoad="display()">
|