简体   繁体   中英

javascript “slideit” function is not working for a header image slideshow

I am just trying to create a slideshow in my header and I'm not sure what I am doing wrong in the coding to make my slideshow work. It has to be something really simple, but I cannot find it. Any ideas?

website is: http://www.daleandhannah.com/CMI/site/index.html

<html>
<head>
<script type="text/javascript">
<!--
var image1=new Image()
image1.src="slideshow1.jpg"
var image2=new Image()
image2.src="slideshow2.gif"
var image3=new Image()
image3.src="thirdcar.gif"
//-->
</script>
</head>
<body>
<img src="firstcar.gif" name="slide" width="100" height="56" />
<script>
<!--
//variable that will increment through the images
var step=1
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<3)
step++
else
step=1
//call function "slideit()" every 2.5 seconds
setTimeout("slideit()",2500)
}
slideit()
//-->
</script>
</body>
</html>

您可以在http://top-answers.net/webdesign/javascript-image-slide-show.html上看到j​​avascript幻灯片的现成代码希望对您有所帮助!

In your code, you have

var image1=new Image()
image1.src="slideshow1.jpg"
var image2=new Image()
image2.src="slideshow2.gif"

http://www.daleandhannah.com/CMI/site/slideshow2.jpg is fine, but http://www.daleandhannah.com/CMI/site/slideshow2.gif gives me a 404 Error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM