This is probably an old subject, as I can find a lot of pages over the web dealing with the matter, but none have a solution that seems to work for me. Sooo I'm here hoping for a cure to my problem.
I'm trying to get a rotating image to house a link that visitors can click on.
Here's code I slapped together:
Code:
<script language="javascript" type="text/javascript">
var imgArray = new Array();
// Enter the names of the images below
imgArray[0]="http://www.555.com/file1.JPG";
imgArray[1]="http://www.555.com/file2.JPG";
imgArray[2]="http://www.555.com/file3.JPG";
// Set up URL array
var URL = new Array();
URL[0] = "http://www.111.com";
URL[1] = "http://www.222.com";
URL[2] = "http://www.333.com";
var newImage = 0 ;
var totalImg = (imgArray.length - 1);
var currentURL = (URL.length - 1);
function cycleImg() {
if (newImage == totalImg) {
newImage = 0 ;
} else {
document.image.src = imgArray[newImage];
document.image.URL = URL[a] ;
// set the time below for length of image display
// i.e., "4*1000" is 4 seconds
setTimeout("cycleImg()", 3*1000);
newImage++;
}
}
</script>
<!-- HTML -->
<body onload="cycleImg();">
<div id="rotator_div">
<p style="text-align:center;"> <strong>Current Sponsors:</strong></p>
<img id="rotating_img" src="http://www.555.com/file1.JPG" name="image"/>
</div>
</body>
Now it only loads the first image, and disappears; plus the image that does load, doesn't have the URL attached to it in a link.
Could anyone please help with the adjustments that I need to make to pull this off?
It's easy to show an alternate solution ( of which there are countless ), but the original problem was an undefined variable. All you had to do was use the error console.
It's easy to show an alternate solution ( of which there are countless ), but the original problem was an undefined variable. All you had to do was use the error console.
Hmm. I don't know what an error console is, but I would be glad to learn if you point me in the right direction. In terms of javascript training I have none, and I'm programming the stuff on a content management system, so I'm not sure if I have any access to developer-type platforms.
Bookmarks