先看看效果吧。
代碼很簡單,只是使用了javascript的setTimeout()函數。
用到的html"
複製代碼 代碼如下:<table>
<td bgcolor="EE8F8F" height="45">
<img src="dg8.gif" src="dg8.gif" name="hr1"><img
src="dg8.gif" name="hr2"><img
src="dgc.gif" name="c"><img
src="dg8.gif" name="mn1"><img
src="dg8.gif" name="mn2"><img
src="dgc.gif" name="c"><img
src="dg8.gif" name="se1"><img
src="dg8.gif" name="se2">
</td></table>
然後是實現了不停的計時的javascript:複製代碼 代碼如下:<script language="javascript"><!--
dg0 = new Image();dg0.src = "dg0.gif";
dg1 = new Image();dg1.src = "dg1.gif";
dg2 = new Image();dg2.src = "dg2.gif";
dg3 = new Image();dg3.src = "dg3.gif";
dg4 = new Image();dg4.src = "dg4.gif";
dg5 = new Image();dg5.src = "dg5.gif";
dg6 = new Image();dg6.src = "dg6.gif";
dg7 = new Image();dg7.src = "dg7.gif";
dg8 = new Image();dg8.src = "dg8.gif";
dg9 = new Image();dg9.src = "dg9.gif";
dgc = new Image();dgc.src = "dgc.gif";
se_d=0;
se_g=0;
mn_g=0;
mn_d=0;
hr_g=0;
hr_d=0;
function dotimer(){
theTime=setTimeout('dotimer()',1000);
//���ﲻ��ʹ��60����4����hr,mn��se
//������ʹ�øߣ���λ4��ʾ
document.hr1.src = 'dg'+hr_g+'.gif';
document.hr2.src = 'dg'+hr_d+'.gif';
document.mn1.src = 'dg'+mn_g+'.gif';
document.mn2.src = 'dg'+mn_d+'.gif';
document.se1.src = 'dg'+se_g+'.gif';
document.se2.src = 'dg'+se_d+'.gif';
if(se_d < 9)
{
se_d=se_d +1;}
else
{
se_d=0;
se_g=se_g+1;
}
if(se_g > 5)
{se_g = 0;
mn_d=mn_d +1 ;
if(mn_d > 9)
{mn_d =0;
mn_g = mn_g+1;}
if(mn_g >5)
{
mn_g=0;
hr_d=hr_d+1;
}
if(hr_d >9)
{
hr_d=0;
hr_g=hr_g+1;
}
}
}
dotimer();
//end
// --></script>
最後附上我用到的幾個圖片: