[英]javascript slideshow not working?
i have created a code for a simple javascript picture slideshow. 我已经为简单的javascript图片幻灯片创建了代码。 so, when i copy the code directly from the website that i learned it from it works.
因此,当我直接从我从它那里学到的网站上复制代码时,它就可以工作。 when i try to recreate the code exactly the same way, it does not work.
当我尝试以完全相同的方式重新创建代码时,它不起作用。 how is this possible?
这怎么可能? i have revised the code thoroughly.
我已经彻底修改了代码。 is javascript not working or what?
javascript不起作用还是什么? the code:
编码:
<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>
<script type="text/javascript">
var image1 = new Image()
image1.src = "sample01.jpg"
var image2 = new Image()
image2.src = "sample02.jpg"
var image3 = new Image()
image3.src = "sample03.jpg"
var image4 = new Image()
image4.src = "sample04.jpg"
var image5 = new Image()
image5.src = "sample05.jpg"
</script>
</head>
<body>
<center>
<img src="sample01.jpg" name="slider1" width=800 height=380 />
<script type="text/javascript">
var x=1;
function slider()
{
document.images.slider1.src = eval("image"+x+".src");
if (x<5)
x++;
else
x=1;
setTimeout=("slider()",10);
}
slider();
</script>
</center>
</body>
</html>
Change 更改
setTimeout=("slider()",10);
by 通过
setTimeout("slider()",10);
var x=1;
function slider()
{
document.images.slider1.src = eval("image"+x+".src");
x= (x+1)%4 +1;
setTimeout(slider,10);
}
setTimeout(slider,10); // 10 is too fast for a slide show (10ms) use at least 1000ms
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.