View Full Version : My Javascript file can't see any images

06-14-2008, 08:21 AM
I am working on an assignment which needs to include a basic image slideshow. I'm fairly positive the code for it is fine. But for some reason it can't seem to see that there are any images in the page. Here are the links (it might be a bit slow, it wasn't designed for the internet.)

http://www.magii.consoleradar.com/work/slideshow.html - The web page
http://www.magii.consoleradar.com/work/slideshow.js - The Javascript file

I have tried it on Firefox and Opera and got the same result on both of them. Anyone got any ideas?

Edit: Sorry should have added I get this in the Firefox error window "Error: document.images.slideshow is undefined"

Philip M
06-14-2008, 08:26 AM
Line 16
Char 2
document.getElementById(...) is null or not an object.

06-14-2008, 08:46 AM
Maybe you wanted like this instead:

var slides = new Array();
var whichimage=0;
slides[0] = "images/slide1.jpg";
slides[1] = "images/slide2.jpg";
slides[2] = "images/slide3.jpg";
slides[3] = "images/slide4.jpg";
slides[4] = "images/slide5.jpg";
slides[5] = "images/slide6.jpg";

document.write("This document contains: ")
document.write(slides.length + " images.") // You might mean this, if not just remove this part
//document.write(document.images.length + " images.") // This is the original one

function slideshow()
var slideshowspeed = 2000;
document.getElementById("slideshow").src = slides[whichimage];
setTimeout('slideshow()', slideshowspeed);

slide3.jpg (http://www.magii.consoleradar.com/work/images/slide3.jpg) and slide4.jpg (http://www.magii.consoleradar.com/work/images/slide4.jpg) does'nt exist (yet).

Hope it helps.

06-14-2008, 08:53 AM
Thanks rangana that seemed to work perfectly. I'm not too sure why mine wasn't working but thanks still.