Hey, I have took some example code from my javascript book which is meant to display a different image every 3 seconds. I have 2 images currently (code is setup for 3) but when the switchImage() function runs, it changes the image, but my second image is not loading, it just shows the alt attribute value and doesn't load my second image. I thought it may be an issue with the src of the images because I was using it in an external javascript file, but I moved it inline within the head of my php file and yet it still doesn't work.
Does anyone possibly know what the issue may be?
Here is the code:
Code:
var currentImgNumber = 1;
var numberOfImages = 3;
function window_onload() {
setTimeout("switchImage()", 3000);
}
function switchImage() {
currentImgNumber++;
document.imgAdvert.src = 'AdvertImage' + currentImgNumber + '.jpg';
if(currentImgNumber < numberOfImages){
setTimeout("switchImage()", 3000);
}
}
as I want the user to be able to click the image as a link. What I want my function to do is set the href attribute of the anchor tag to the relative image when it has changed.
I have updated my function but it doesn't seem to be running at all now. When I load the page, the images are not switching.
Here is my code:
Code:
var links = new Array();
links[1] = "http://z3.invisionfree.com/HunterKillerz/index.php?act=idx";
links[2] = "http://labtec.0fees.net/Gardenable/index.htm";
links[3] = "http://gamebanana.com/";
var currentImgNumber = 1;
var numberOfImages = 3;
function window_onload() {
setInterval("switchImage()", 3000);
}
function switchImage() {
currentImgNumber++;
document.advertLink.href = links[currentImgNumber];
document.imgAdvert.src = 'images/AdvertImage' + currentImgNumber + '.jpg';
if(currentImgNumber == 3){
currentImgNumber = 0;
}
}
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".