javascript vs. ajax slide show?

cdparmeter

New member
I'm building a page that has a simple easy javascript slide show. the hard thing is I want to include several slide shows different folders of images on the same page. the folders all have different numbers of images in them. what I'm looking for is a catch for the javascript to realize there isn't a file that exists by that name and start the loop over...... I don't know if I can do it with javascript or if I have to move up to ajax....

<script type="text/javascript">
var filename;
var image=1;
var t;
function switchimage(){
image=image+1

document.getElementById('image').src=filename
+ "/" + image + ".jpg";
t=setTimeout(switchimage, 2500);
if(image=?????? if the image doesn't exist){
image=1}
}
the the file name will change by changing the filename var.
hopefully that makes enough sense that someone will understand thanks for the help.
 
Check the height or width of the images ONCE IT HAS FINISHED LOADING - if either are zero it didn't load correctly.

document.getElementById('image').onload = function () {
if (this.width == 0) {
// the image didn't load
}
}

document.getElementById('image').src = something;
 
Check the height or width of the images ONCE IT HAS FINISHED LOADING - if either are zero it didn't load correctly.

document.getElementById('image').onload = function () {
if (this.width == 0) {
// the image didn't load
}
}

document.getElementById('image').src = something;
 
Back
Top