js81:Image对象,几张图像缓存完之后动画显示,form.elements[],document.images[]
原文发布时间为:2008-11-09 —— 来源于本人的百度文章 [由搬家工具导入]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript">
var imgs=new Array(3);
var curimg=0;
var imgload=0;
var start;
for(var i=0;i<imgs.length;i++){
imgs[i]=new Image();
imgs[i].src= "../../图片/视觉/image00"+(i+1)+".gif";
imgs[i].onLoad=count();
}
function count(){
imgload++;
if(imgload==3)
start=setInterval("showimg();",1000);
}
function showimg(){
if(curimg==2)
curimg=0;
else
curimg++;
document.pic.src=imgs[curimg].src;
}
</script>
<title>js8</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="textfield"/>
</label>
<p>
<label>
<input name="an1" type="button" id="an1" value="aaaa" onclick="document.form1.elements[0].value=this.value;" />
</label>
<label>
<input name="an2" type="button" id="an2" value="bbbb" onclick="this.form.elements[0].value=this.value" />
</label>
<label>
<input name="an3" type="button" id="an3" value="cccc" onclick="this.form.textfield.value=this.value" />
</label>
<label>
<input name="an4" type="button" id="an4" value="dddd" onclick="window.open('','ad','height=300,width=300');" />
</label>
</p>
</form>
<input name="an42" type="button" id="an42" value="showanotherpicture" onclick="document.pic.src='../../图片/视觉/image003.gif'" />
<img src="../../图片/视觉/image002.gif" name="pic"/>
<script type="text/javascript">
alert(document.title+" "+document.URL+" "+document.lastModified);
document.title="love";
document.write("hello\n","world","!");
document.write(document.images.length);
document.write(document.images[0].name);
</script>
</body>
</html>