I have added a simple javascript banner rotator created with a free online generator into one of my banners via admin>tools>banner manager
I have simply pasted the following generated code into the 'HTML Text:' box on the banner manager page.
<script type="text/javascript">
var imgs1 = new Array("/images/banners/free_box_banner.jpg","/images/banners/free_shipping_banner.jpg");
var lnks1 = new Array("http://www.mydomain.com/index.php?main_page=page&id=25","http://www.mydomain.com/index.php?main_page=shippinginfo");
var alt1 = new Array(" Free Gift Box!","Free Shipping Worldwide");
var currentAd1 = 0;
var imgCt1 = 2;
function cycle1() {
if (currentAd1 == imgCt1) {
currentAd1 = 0;
}
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
banner1.src=imgs1[currentAd1]
banner1.alt=alt1[currentAd1]
document.getElementById('adLink1').href=lnks1[currentAd1]
currentAd1++;
}
window.setInterval("cycle1()",4000);
</script>
<a href="http://www.mydomain.com/index.php?main_page=page&id=25"" id="adLink1" target="_top">
<img src="/images/banners/free_box_banner.jpg" id="adBanner1" border="0" width="537" height="80"></a>
The script works as planned, BUT for some reason it hangs on initial page load. So instead of showing the first image for 4 seconds then rotating to the next it waits 8 seconds. After the first rotation it works normally.
Can anyone tell me how to fix this?
Thanks :)
Bookmarks