<title>Untitled Document</title><Script>functionTodou (n) {if(n<Ten){ return '0'+N; }Else{ return "'+N; //guaranteed to return strings, avoid putting them together and adding them.}}window.onload=function (){ varaimg=document.getElementsByTagName ('img'); functiontick () {varodate=NewDate (); varStr=Todou (Odate.gethours ())+Todou (Odate.getminutes ())+Todou (Odate.getseconds ()); for(varI=0; I<Aimg.length;i++) {aimg[i].src='images/'+Str.charat (i)+'. gif'; }} setinterval (tick, +); Tick (); };</Script></Head><Bodystyle= "background: #999; color:white;"><imgsrc= "Images/0.gif"><imgsrc= "Images/0.gif">:<imgsrc= "Images/0.gif"><imgsrc= "Images/0.gif">:<imgsrc= "Images/0.gif"><imgsrc= "Images/0.gif"></Body>
Minor problem:
var str= ' abcdef ';
Alert (str[0]); Show undefined under IE7
Use Str.charat (0) to solve this compatibility problem
Digital clock
Get system time
Date Object
GetHours, getminutes, getseconds
Date Object Other methods
Year getFullYear ()
Month GetMonth () starting from 0
Day GetDate ()
Week GetDay () 0,1,2,3,4,5,6 0 for weekend
Use of JS Timer--Digital clock