方法一
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<div id="div1" ></div>
<div id="div2" ></div>
<script>
var array1 = new Array();
array1[0] = new Array();
array1[1] = new Array();
array1[2] = new Array();
array1[0][0] = "内容1";
array1[0][1] = "背景音乐1";
array1[0][2] = 1000;//持续时间
array1[1][0] = "内容2";
array1[1][1] = "背景音乐2";
array1[1][2] = 2000;//持续时间
array1[2][0] = "内容3";
array1[2][1] = "背景音乐3";
array1[2][2] = 3000;//持续时间
setTimeout("show(0)",0);//这里的0是用来设置第一一运行的延时.
function show(index)
{
var tempIndex,tempTime; //tempIndex是当前一级数组的下标;tempTime是当前一级数组要持续的时间.
if (index == array1.length) //3是一级数组个数.
{
index = -1;//因为这是一级数组最后一个,进行下一个一级数组的循环是下标应为0,但下面index++的,所以现在置为-1;
tempTime =0;//一级数组循环完毕后进入第二次循环时候的延时.
tempIndex =array1.length-1 //2是一级数组的倒数第二个数组.
}
else
{
tempTime = array1[index][2];
tempIndex = index;
}
div1.innerHTML = array1[tempIndex][0];
div2.innerHTML = array1[tempIndex][1];
index++;
//alert(index+"AA"+tempTime);
setTimeout("show("+index+")",tempTime);
}
</script>
</BODY>
</HTML>
方法二
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY onLoad="loadshow();">
<div id="div1" ></div>
<div id="div2" ></div>
<script>
var array1 = new Array();
array1[0] = new Array();
array1[1] = new Array();
array1[2] = new Array();
array1[0][0] = "内容1";
array1[0][1] = "背景音乐1";
array1[0][2] = 1000;//持续时间
array1[1][0] = "内容2";
array1[1][1] = "背景音乐2";
array1[1][2] = 1000;//持续时间
array1[2][0] = "内容3";
array1[2][1] = "背景音乐3";
array1[2][2] = 1000;//持续时间
function loadshow()
{
setTimeout("show(0)",0);
}
function show(index)
{
div1.innerHTML = array1[index][0];
div2.innerHTML = array1[index][1];
index++;
if (index >= 3)
{
setTimeout("loadshow()",array1[2][2]);
}
else
{
setTimeout("show("+index+")",array1[index-1][2]);
}
}
</script>
</BODY>
</HTML>
posted on 2006-04-03 14:41
汪杰 阅读(228)
评论(0) 编辑 收藏 引用 所属分类:
javascript 、
hengxing网站js