显示当前时间<script>var day=""; var month=""; var ampm=""; var ampmhour=""; var myweekday=""; var year=""; mydate=new Date(); myweekday=mydate.getDay(); mymonth=mydate.getMonth()+1; myday= mydate.getDate(); myyear= mydate.getYear(); year=(myyear > 200) ? myyear : 1900 + myyear; if(myweekday == 0) weekday=" 星期日 "; else if(myweekday == 1) weekday=" 星期一 "; else if(myweekday == 2) weekday=" 星期二 "; else if(myweekday == 3) weekday=" 星期三 "; else if(myweekday == 4) weekday=" 星期四 "; else if(myweekday == 5) weekday=" 星期五 "; else if(myweekday == 6) weekday=" 星期六 "; document.write(year+"年"+mymonth+"月"+myday+"日 "+weekday); </script> <SCRIPT language=Javascript1.2> <!-- //以下是顯示時間 var tags_before_clock = "" var tags_after_clock = "" if(navigator.appName == "Netscape") { document.write('<layer id="clock"></layer>'); } if (navigator.appVersion.indexOf("MSIE") != -1){ document.write('<span id="clock"></span>'); } function showclock() { var date = new Date(); var hour = date.getHours(); var min = date.getMinutes(); var sec = date.getSeconds(); var col = ":"; var spc = ""; var apm; if ( hour >12 ) { apm="P.M."; hour=hour-12; } else { apm="A.M."; } if (hour == 0) hour=12; if (min<=9) min="0"+min; if (sec<=9) sec="0"+sec; if(navigator.appName == "Netscape") { document.clock.document.write(tags_before_clock +hour+col+min+col+sec+spc+tags_after_clock); document.clock.document.close(); } if (navigator.appVersion.indexOf("MSIE") != -1) { clock.innerHTML = tags_before_clock+hour +col+min+col+sec; } } setInterval("showclock()",1000); //--> </SCRIPT> <script type="text/javascript"> function clock(){ var nowtime=new Date(); var flag=""; var hours=nowtime.getHours(); if(hours>12){ hours-=12; flag=""; } hours=hours>9?hours:"0"+hours; var minutes=nowtime.getMinutes(); minutes=minutes>9?minutes:"0"+minutes; var seconds=nowtime.getSeconds(); seconds=seconds>9?seconds:"0"+seconds; var disptime=hours+":"+minutes+":"+seconds+""+flag; document.getElementById("clock").innerHTML=disptime; setTimeout("clock()",1000); } </script> <script type="text/javascript"> clock(); </script>