网页上显示时间
代码如下:
<TABLE> <TR> <TD><span id="localtime"></span> <script> function showLocale(objD) { var dn, str; var hh = objD.getHours(); var mm = objD.getMinutes(); var ss = objD.getSeconds(); str = (objD.getMonth() + 1) + "月" + objD.getDate() +"日"; if(hh<10) hh = '0' + hh; if(mm<10) mm = '0' + mm; if(ss<10) ss = '0' + ss; str += " " + hh + ":" + mm + ":" + ss; return(str); } function tick() { var today; today = new Date(); document.getElementById("localtime").innerHTML = showLocale(today); window.setTimeout("tick()", 1000); } tick(); </script> </TD> </TR> </TABLE>