///pc/img/blank.gif" width="12" height="8">当前位置:///default.htm" class="under">亿度网络 -> ///pc/index.htm" class="under">网页制作教程 -> JavaScript实例
///pc/homepage/javascript/sample/img/bule.gif" width="207" height="13"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/js.gif" width="186" height="20"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
    随时间变化的图形 ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
    ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  
效 果 演 示 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
请  
不  
停  
的  
刷  
新  
屏  
幕  
,  
以  
观  
看  
效  
果  
。   

   

 

   
 
源代码如下 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">



这段程序放在<body>与</body>之间

   
源程序讲解: ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
  ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  

var dt = new Date();

定义一个新的时间对象。
var hr = dt.getSeconds();
定义一个变量,获得当前的秒数。
if (hr<=20)
hr=7;
当前的秒数小于20时,hr=7。
else if
(hr<=40) hr=8;
当前的秒数小于40大于20时,hr=8。
else hr=9;
当前的秒数大于40小于60时,hr=9。
var msg="<IMG SRC=img/"+hr+".jpg>";
document.write(msg);
设置变量msg的值为要显示图的路径,并输出这张图。

注:本例中所用到的三张图放在与本页面同级的"img"文件夹内,名字分别为7.jpg,8.jpg,9.jpg。

  ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
 

 

网页制作 网页设计 网站建设 网站设计 网站制作 做网站 做网页