Wednesday, August 27, 2008

Slide Show Using Javascript

"// The list of images to display in the slideshow"
//creating a array of the image object
"var image=new Array("images/image1.jpg",
"images/image2.jpg",
"images/image3.jpg",
"images/image4.jpg",
"images/image5.jpg",
"images/image6.jpg",
"images/image7.jpg",
"images/image8.jpg",
"images/image9.jpg",
"images/image10.jpg"

" )"

//variable that will increment through the images
"var num=0"

// set the delay between images
var timeDelay

//preload the images in the cache so that the images load faster
//create new instance of images in memory

var imagePreload=new Array()
"for (i=0;i{
imagePreload[i]=new Image()
// set the src attribute
imagePreload[i].src=image[i]
}






//for automatic Slideshow of the Images
function slideshow_automatic()
{

if (num {
num++
//if last image is reached,display the first image
if (num==image.length)
num=0

//sets the timer value to 4 seconds,we can create a timing loop by using the setTimeout method
timeDelay=setTimeout("slideshow_automatic()",4000)
document.images.slideShow.src=image[num]
}


}"

No comments: