<body>
<div id="timer">
<img src="0.gif" name="h0" width="15" height="28">
<img src="0.gif" name="h1" width="15" height="28">
<img src="x.gif" width="15" height="28">
<img src="0.gif" name="m0" width="15" height="28">
<img src="0.gif" name="m1" width="15" height="28">
<img src="x.gif" width="15" height="28">
<img src="0.gif" name="s0" width="15" height="28">
<img src="0.gif" name="s1" width="15" height="28">
</div>
<script language="javascript">
 var t_h,t_m,t_s;
image0="0.gif";
image1="1.gif";
image2="2.gif";
image3="3.gif";
image4="4.gif";
image5="5.gif";
image6="6.gif";
image7="7.gif";
image8="8.gif";
image9="0.gif";
 change_time();
 function change_time(){
 var v0,v1;
 time=new Date();
 t_h=time.getHours();
 t_m=time.getMinutes();
 t_s=time.getSeconds();
 vo=parseInt(t_h/10);
 v1=t_h%10;
 document.images['h0'].src=eval("image"+vo);
 document.images['h1'].src=eval("image"+v1);
 v0=parseInt(t_m/10);
 v1=t_m%10;
 document.images['m0'].src=eval("image"+vo);
 document.images['m1'].src=eval("image"+v1);
 v0=parseInt(t_s/10);
 v1=t_s%10;
 document.images['s0'].src=eval("image"+vo);
 document.images['s1'].src=eval("image"+v1);
 setTimeout("change_time()",100);
 }
 </script>
</body>
</html>

解决方案 »

  1.   

    <html>
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>时间</title>
    </head>
    <body>
    <div id="timer">
    <img src="0.jpg" name="h0" width="15" height="28">
    <img src="0.jpg" name="h1" width="15" height="28">
    <img src="x.jpg" width="15" height="28">
    <img src="0.jpg" name="m0" width="15" height="28">
    <img src="0.jpg" name="m1" width="15" height="28">
    <img src="x.jpg" width="15" height="28">
    <img src="0.jpg" name="s0" width="15" height="28">
    <img src="0.jpg" name="s1" width="15" height="28">
    </div>
    <script language="javascript">
     var t_h,t_m,t_s;
     
     image0=new Image();image0.src="010.gif";
     image1=new Image();image1.src="001.gif";
     image2=new Image();image2.src="002.gif";
     image3=new Image();image3.src="003.gif";
     image4=new Image();image4.src="004.gif";
     image5=new Image();image5.src="005.gif";
     image6=new Image();image6.src="006.gif";
     image7=new Image();image7.src="007.gif";
     image8=new Image();image8.src="008.gif";
     image9=new Image();image9.src="011.gif";
     change_time();
     function change_time(){
     var v0,v1;
     time=new Date();
     t_h=time.getHours();
     t_m=time.getMinutes();
     t_s=time.getSeconds();
     v0=parseInt(t_h/10);
     v1=t_h%10;
     document.images['h0'].src=eval("image"+v0+".src");
     document.images['h1'].src=eval("image"+v1+".src");
     v0=parseInt(t_m/10);
     v1=t_m%10;
     document.images['m0'].src=eval("image"+v0+".src");
     document.images['m1'].src=eval("image"+v1+".src");
     v0=parseInt(t_s/10);
     v1=t_s%10;
     document.images['s0'].src=eval("image"+v0+".src");
     document.images['s1'].src=eval("image"+v1+".src");
     setTimeout("change_time()",100);
     }
     </script>
    </body>
    </html>
      

  2.   

    注意vo和v0的区别
    image对象是src属性来指定图片
      

  3.   

    或者
    <script language="javascript">
     var t_h,t_m,t_s;
     image0=new Image();image0.src="0.gif";
     image1=new Image();image1.src="1.gif";
     image2=new Image();image2.src="2.gif";
     image3=new Image();image3.src="3.gif";
     image4=new Image();image4.src="4.gif";
     image5=new Image();image5.src="5.gif";
     image6=new Image();image6.src="6.gif";
     image7=new Image();image7.src="7.gif";
     image8=new Image();image8.src="8.gif";
     image9=new Image();image9.src="0.gif";
     change_time();
     function change_time(){
     var v0,v1;
     time=new Date();
     t_h=time.getHours();
     t_m=time.getMinutes();
     t_s=time.getSeconds();
     vo=parseInt(t_h/10);
     v1=t_h%10;
     document.images['h0'].src=eval("image"+vo+".src");
     document.images['h1'].src=eval("image"+v1+".src");
     v0=parseInt(t_m/10);
     v1=t_m%10;
     document.images['m0'].src=eval("image"+vo+".src");
     document.images['m1'].src=eval("image"+v1+".src");
     v0=parseInt(t_s/10);
     v1=t_s%10;
     document.images['s0'].src=eval("image"+vo+".src");
     document.images['s1'].src=eval("image"+v1+".src");
     setTimeout("change_time()",100);
     }
     </script>
      

  4.   

    呵呵
    wangxj0600(闭门思过中) 比我快了一点