SLIDESHOW

This sample script created a mannual slideshow where the user can click the forward and backward buttons to view the slides. The script declares an array of images and created a function ShowSlides to display the images when the user clicks the buttons.

The script::

<script language="Javascript">
MySlides=new Array('banner1.jpg','banner2.jpg','banner3.jpg','banner4.jpg')
Slide=0
function ShowSlides(SlideNumber){

{ Slide=Slide+SlideNumber
if (Slide>MySlides.length-1){
Slide=0
}
if (Slide<0) {
Slide=MySlides.length-1
}
document.DisplaySlide.src=MySlides[Slide]
}
}
</script>
</head>

<input type="button" value="Back" onclick="ShowSlides(-1)">
<input type="button" value="Forward" onclick="ShowSlides(1)">

The script in action


 


[Back to JavaScript Samples]