7-6.htm

来自「JScript网页特效,包含很多的实现网页特效的方法.」· HTM 代码 · 共 61 行

HTM
61
字号
<html>
<head>
<title>§7.6 多幅图片不断轮换显示</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!-- Begin Code
var interval = 2.5; // 图片变换时间,以秒为单位
var random_display = 1; // 1为随机显示,0为顺序显示
interval *= 1000;

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("001.gif");
image_list[image_index++] = new imageItem("002.gif");
image_list[image_index++] = new imageItem("003.gif");
image_list[image_index++] = new imageItem("004.gif");
var number_of_image = image_list.length;

function imageItem(image_location) 
{ 
  this.image_item = new Image();
  this.image_item.src = image_location;
}

function get_ImageItemLocation(imageObj) 
{
  return(imageObj.image_item.src)
}

function getNextImage() 
{
  if (random_display) 
  {
    image_index = Math.floor(Math.random() * 10)%4;
  }
  else 
  {
    image_index = (image_index+1) % number_of_image;
  }
  var new_image = get_ImageItemLocation(image_list[image_index]);
  return(new_image);
}

function rotateImage(place) 
{
  var new_image = getNextImage();
  document[place].src = new_image;
  var recur_call = "rotateImage('"+place+"')";
  setTimeout(recur_call, interval);
}
//  End Code-->
</script>

</head>

<body bgcolor="#FFFFFF" OnLoad="rotateImage('rImage')">
<p><img name="rImage" src="001.gif" width=100 height=75> </p>
<p>上图为四幅图来回变换显示。</p>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?