Quote:
Originally Posted by Gloria Culver
[...]
Got some time this evening and substituted the rotating code for the static code. I must have something wrong because nothing is appearing. This is what I have:
<center>
<script language="JavaScript">
images = new Array(2);
images[0] = "<a href = 'http://www.LinkToBannersWebsite.com target=_new><img src='http://www.jouster.com/forums/images/banner/otis.gif' alt='Hover text'></a>";
images[1] = "<a href = 'http://www.LinkToBannersWebsite.com target=_new><img src='http://www.jouster.com/forums/images/banner/turnerslings.jpg'
alt='Hover text'></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
</script>
</center>
Is it correct or do I have a boo-boo that I just can't see?
[...]
|
There are missing some single quotes.
The error was in this (here corrected line) :
images[0] = "<a href = 'http://www.LinkToBannersWebsiteA.com' target='_blank'><img src='http://www.PlaceWhereTheBannerIsStored_a.gif' alt='Funny hover text'></a>";
Complete and correct code is:
HTML Code:
<center>
<script language="JavaScript">
images = new Array(4);
images[0] = "<a href = 'http://www.LinkToBannersWebsiteA.com' target='_blank'><img src='http://www.PlaceWhereTheBannerIsStored_a.gif' alt='Funny hover text A'></a>";
images[1] = "<a href = 'http://www.LinkToBannersWebsiteB.com' target='_blank'><img src='http://www.PlaceWhereTheBannerIsStored_b.gif' alt='Sad hover text B'></a>";
images[2] = "<a href = 'http://www.LinkToBannersWebsiteC.com' target='_blank'><img src='http://www.PlaceWhereTheBannerIsStored_c.gif' alt='Stupid hover text C'></a>";
images[3] = "<a href = 'http://www.LinkToBannersWebsiteD.com' target='_blank'><img src='http://www.PlaceWhereTheBannerIsStored_d.gif' alt='Intelligent hover text D'></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
</script>
</center>
I also use target='_blank' instead of target='_new' but I don't know if this makes any difference, my programming days were somewhere back in the past...
I hope this helps somebody - at least to save some hours of searching the error.