js动态显示当前系统时间...
时间:2010-08-13 来源:DavyChenflash
所有时间为 GMT+8, 现在时间是 <!-- 动态显示当前时间 --> <script language=JavaScript> today=new Date(); function initArray(){ this.length=initArray.arguments.length;//传递参数给当前函数的参数个数 for(var i=0;i<this.length;i++) this[i+1]=initArray.arguments[i]; } var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); document.write(today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日 ",d[today.getDay()+1]); </script> <span id="liveclock" style"="width: "109px; </span> <!--显示时间--> <SCRIPT language=javascript> function www_mdrcw_com(){ var Digital=new Date(); var hours=Digital.getHours(); var minutes=Digital.getMinutes(); var seconds=Digital.getSeconds(); if(minutes<=9) minutes="0"+minutes; if(seconds<=9) seconds="0"+seconds; myclock="<font>"+hours+":"+minutes+":"+seconds+"</font>"; if(document.layers){ document.layers.liveclock.document.write(myclock); document.layers.liveclock.document.close(); }else if(document.all) liveclock.innerHTML=myclock; setTimeout("www_mdrcw_com()",1000); } www_mdrcw_com(); </SCRIPT>
显示效果如下:
说明:document.layers对象是Netscape支持的对象,而document.all对象则是只有IE才支持的对象,Netscape则不支持。