js 钟表

 1 <script>
 2 document.write('<TR><td colspan="3" align="right" bgcolor="#C6C3C6" valign="bottom">');
 3 document.write('<font class="whiteword"><b>现在时间</b></font></td><td valign="bottom" colspan="4" bgcolor="#C6C3C6">');
 4 document.write('<div id="clock" class="clock"></div>');
 5 document.write('</TD>');
 6 </script>
 7 
 8 <script LANGUAGE="JavaScript">
 9 
10 var timerID = null;
11 var timerRunning = false;
12 function stopclock (){
13 
14 if(timerRunning)
15 clearTimeout(timerID);
16 timerRunning = false;
17 
18 
19 }
20 
21 function showtime () {
22 var now = new Date();
23 var hours = now.getHours();
24 var minutes = now.getMinutes();
25 var seconds = now.getSeconds();
26 var timeValue = " " + ((hours <10) ? "0" :"")+hours;
27 timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
28 timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
29 document.getElementById("clock").innerHTML=timeValue;
30 timerID = setTimeout("showtime()",1000);
31 timerRunning = true;
32 }
33 function startclock () {
34 stopclock();
35 showtime();
36 }
37 
38 </script>
39 <script language="javascript">
40 
41 startclock();
42 </script>
白发三千丈
原文地址:https://www.cnblogs.com/sanpoye/p/2541283.html