javascript 写的一个简单的timer
先看看效果吧。
代码很简单,只是使用了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>
最后附上我用到的几个图片:
相关推荐
nmgxzm00 2020-11-10
ifconfig 2020-10-14
hhanbj 2020-11-17
zfszhangyuan 2020-11-16
古叶峰 2020-11-16
一个智障 2020-11-15
jipengx 2020-11-12
81427005 2020-11-11
xixixi 2020-11-11
游走的豚鼠君 2020-11-10
苗疆三刀的随手记 2020-11-10
Web卓不凡 2020-11-03
小飞侠V 2020-11-02
帕尼尼 2020-10-30
爱读书的旅行者 2020-10-26
帕尼尼 2020-10-23
杏仁技术站 2020-10-23
淼寒儿 2020-10-22