JavaScript 三张图片交替地动画显示(一下我写的代码错在哪里?)
<html><head><scripttype="text/javascript">vartheA=newArray(3);for(i...
<html><head><script type="text/javascript">var theA=new Array(3);for(i=0,n=theA.length;i<n;i++){theA[i]=new Image(); theA[i].src=i+'.gif';}var currentImage=1;var run=ture;var speed=1000;function changeSize1(){if(!document.images)return;if(!run)return;document.getElementById("myImage").src=theA[currentImage].src;currentImage++;if(currentImage>theA.length-1)currentImage=0;setTimeout('changeSize1()',speed);}</script></head><body><img id="myImage" src="0.gif" border="0" onload="changeSize1()"></body></html>请完善我的代码?修改后我要完整的代码!
展开
展开全部
这样就行了
<html>
<head>
<script type="text/javascript">
var theA=new Array(3);
for(i=0,n=theA.length;i<n;i++)
{
theA[i]=new Image();
theA[i].src=i+'.gif';
}
var currentImage=1;
var run=true;
var speed=1000;
function changeSize1()
{
if(!document.images) return;
if(!run) return;
document.getElementById("myImage").src=theA[currentImage].src;
currentImage++;
if(currentImage>theA.length-1) currentImage=0;
setTimeout('changeSize1()',speed);
}
window.onload = changeSize1;
</script>
</head>
<body>
<img id="myImage" src="0.gif" border="0" title="123">
</body>
</html>
顺便回楼上的IMG有onload事件,只不过是做图片加载判断用的,不适用于这个例子。
<html>
<head>
<script type="text/javascript">
var theA=new Array(3);
for(i=0,n=theA.length;i<n;i++)
{
theA[i]=new Image();
theA[i].src=i+'.gif';
}
var currentImage=1;
var run=true;
var speed=1000;
function changeSize1()
{
if(!document.images) return;
if(!run) return;
document.getElementById("myImage").src=theA[currentImage].src;
currentImage++;
if(currentImage>theA.length-1) currentImage=0;
setTimeout('changeSize1()',speed);
}
window.onload = changeSize1;
</script>
</head>
<body>
<img id="myImage" src="0.gif" border="0" title="123">
</body>
</html>
顺便回楼上的IMG有onload事件,只不过是做图片加载判断用的,不适用于这个例子。
展开全部
<html>
<head>
<script type="text/javascript">
var theA = new Array(3);
for (i = 0, n = theA.length; i < n; i++) {
theA[i] = new Image();
theA[i].src = "images/"+(i+1) + '.jpg';
}
var currentImage = 1;
var run = true;
var speed = 1000;
function changeSize1() {
if (!document.images)
return;
if (!run)
return;
document.getElementById("myImage").src = theA[currentImage].src;
currentImage++;
if (currentImage > theA.length - 1)
currentImage = 0;
setTimeout('changeSize1()', speed);
}
</script>
</head>
<body onload="changeSize1()">
<img id="myImage" src="0.gif" border="0" >
</body>
</html>
两处错误
1.var run = true; 你写错单词了.
2.img标签没有onload 的事件
<head>
<script type="text/javascript">
var theA = new Array(3);
for (i = 0, n = theA.length; i < n; i++) {
theA[i] = new Image();
theA[i].src = "images/"+(i+1) + '.jpg';
}
var currentImage = 1;
var run = true;
var speed = 1000;
function changeSize1() {
if (!document.images)
return;
if (!run)
return;
document.getElementById("myImage").src = theA[currentImage].src;
currentImage++;
if (currentImage > theA.length - 1)
currentImage = 0;
setTimeout('changeSize1()', speed);
}
</script>
</head>
<body onload="changeSize1()">
<img id="myImage" src="0.gif" border="0" >
</body>
</html>
两处错误
1.var run = true; 你写错单词了.
2.img标签没有onload 的事件
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询