This is inside the head tag
<script type="text/javascript">
var image1=new Image()
image1.src="https://dl.dropbox.com/u/70582811/hand-eye.jpg"
var image2=new Image()
image2.src="https://dl.dropbox.com/u/70582811/floating.JPG"
var image3=new Image()
image3.src="https://dl.dropbox.com/u/70582811/lovers%20ng.jpg"
</script>
This is in the body tag
<script type="text/javascript">
var step=1
function slideit(){
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<3)
step++
else
step=1
}
slideit()
</script>
So I found this code for creating a slideshow, where I just click to step up an image. I'm calling it from a button. But I can't figure out how to alter this code so I can step back instead of forward when a different button is pressed that is a previous button. I'd appreciate any help, I'm not the best at javascript at all. Thanks in advance.
This is where I'm at: http://slidetester.tumblr.com/
You will need to make it so rather than incrementing the picture via step++
the picture number is decremented. Look up how to do this. Also you will need to change the condition for when it runs out of pictures to go back to. I don't want to give you the full code as this should be a learning experience.
I'm assuming you know how to make a button and assign a separate function to it, so instead of slideit() we can call another function which we can call slideitbackwards()
function slideitbackwards() {
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step > 1) //Change this line to the minimum image number
step-- //subtract instead of add
else
step = 3 //Set this to maximum value instead of minimum
}
创建一个新函数并通过按钮触发它:function slideitBack(){if(!document.images)返回document.images.slide.src = eval(“ image” + step +“。src”)if(step> 1 )step-- else step = 3}
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.