Forum Moderators: open
So I have looked everywhere for a banner code that would rotate in and out with images along with different links to go to various places. So I ran across this code by Heidi Allen. I have the images rotating in and out just fine BUT the links do not change for each graphic.
I have looked everywhere for some help on this and every example I have seen has the same problem, the links do not rotate with each image.
So I was hoping that the gurus here could lend a hand:)
I have the main "welcome.htm" page with this code in the header:
<script language="JavaScript" src="custom/functions.js"></script>
That pulls all the functions for this script and the script itself looks like this:
var image="";
var banners=0;
function cycle() {
if (++banners > 3) banners=1;
loadbanners();
document.banner1.src = image;
window.setTimeout('cycle();',1000);
}
function loadbanners() {
if (banners==1)
{
image="custom/images/1.jpg";
}
if (banners==2)
{
image="custom/images/2.jpg";
}
if (banners==3)
{
image="custom/images/3.jpg";
}
}
var link = "main.htm"
function urlswitch() {
if (banners==1)
{
link = "test.htm";
}
if (banners==2)
{
link = "test2.htm";
}
if (banners==3)
{
link = "main.htm";
}
return link;
}
On the welcome.htm page I have this code (where i would like the image to show up) which pulls the data:
<a href="main.htm" onclick="this.href=urlswitch()">
<img width="193" height="128" border="0" src="custom/images/man.jpg" name="banner1"></a>
What I don't get is why the links are not being pulled. I have done some research on the "urlswitch" and from what my novice eye can tell it should be setup correctly. Is there something I am missing here? I'd really like to lay this issue to rest as no other forum or user has been able too.
I just chose "onMouseOver" instead of onclick. The javascript was working, but didn't appear it was working because as the images changed the link didn't...so it gave the illusion that it wasn't working.
Also be sure to include the onLoad="window.setTimeout('cycle();',1000);(loadbanners());(urlswitch());"
in the BODY tag:)
Sweet! Thanks anyway fellas:)