Hi there, I am running a few test and trying to practice a bit with javascript
I have come up with a script which is meant to swap images but it is producing errors. I had tried to debug with firebug but it is not going well at all and I am not quite sure what i have done wrong. I have done a similar script before but this time it is external and the function call is within the script itself, so nothing withing the html.
Anyway, here's what I came up with: antobbo.webspace.virginmedia.com/test/test.htm
the script code is here - external script script.js:
var all_images = new Array (
"animal_full_1.jpg",
"animal_full_2.jpg",
"animal_full_3.jpg",
"animal_full_4.jpg",
"animal_full_5.jpg",
"animal_full_6.jpg",
"animal_full_7.jpg",
"animal_full_8.jpg",
"animal_full_9.jpg",
"animal_full_10.jpg",
"animal_full_11.jpg",
"animal_full_12.jpg"
);
var frame = 0;
function swapImages(){
setInterval("animate()", 5000);
var image = document.getElementById("the_image");
}
function animate(){
frame +=1;
if(frame > all_images.length){
frame = 0;
}
image.src = all_images[frame];
}
swapImages();
When I open the page in firefox nothing happens...any idea please?
Firefox comes back with:
"image is not definedimage.src = all_images[frame];
"