...

View Full Version : PLEASE HELP: Banner Rotator Problem



raven_101
03-12-2004, 10:02 AM
I worked all night last night and got my Banner rotator working perfectly. Then I get an message from someone saying it isn't working! I go check it out, and for some reason it won't work in Netscape. It works perfect in IE.

Here is the script: can anyone help me out? The whole thing is in the BODY section. The banners rotate correctly, but the link is always the same one! Like I said it works fine in IE.

<script language="JavaScript">
var imgs1 = new Array("http://www.shophoenixproject.com/banners/midwest.gif","http://www.shophoenixproject.com/banners/shonut.gif","http://www.shophoenixproject.com/banners/sfc.gif")
var lnks1 = new Array("http://www.midwestsho.com/","http://www.shonutperformance.com/","http://www.shoforum.com/ubb/ultimatebb.php?ubb=get_topic;f=6;t=001714")
var currentdate = new Date();
var currentAd1 = randomRange(2);
var imgCt1 = 3

function randomRange(inMin,inMax) {
var min = 0, max = 0;
if (inMin) min = inMin;
if (inMax) max = inMax;
if (min > max) {
var swop = min
min = max
max = swop
}
return min + Math.floor(Math.random() * (max - min + 1))
}


function cycle1() {
currentAd1++
if (currentAd1 == imgCt1) {
currentAd1 = 0
}
document.adBanner1.src=imgs1[currentAd1]
adLink1.href=lnks1[currentAd1]
}

var timer = window.setInterval("cycle1()",4000);

</script>
<a href="http://www.midwestsho.com/" name="adLink1" target="_blank"><img src="http://www.shophoenixproject.com/banners/midwest.gif" name="adBanner1" border="0" width="468" height="60"></a>
<script language="JavaScript">
cycle1()
</script>

This page can be viewed at http://www.shophoenixproject.com/parts.htm

Garadon
03-12-2004, 10:39 AM
adLink1.href=lnks1[currentAd1]

try

document.adLink1.href=lnks1[currentAd1]

raven_101
03-12-2004, 10:41 AM
I tried that already, it didn't help :(

Willy Duitt
03-12-2004, 10:45 AM
I noticed that you are only passing one arguement.

eg: var currentAd1 = randomRange(2);

.....Willy

raven_101
03-12-2004, 10:51 AM
Originally posted by Willy Duitt
I noticed that you are only passing one arguement.

eg: var currentAd1 = randomRange(2);

.....Willy

0,1, and 2

That part is working fine, because the banners are displaying correctly. It's the links that aren't...

glenngv
03-12-2004, 10:59 AM
You are not referencing the link correctly which IE allows.
Here's the correct one:

document.links['adLink1'].href=lnks1[currentAd1];

To debug in Netscape, type javascript&#58; in the address bar to see the javascript console.

raven_101
03-12-2004, 11:02 AM
You've got to be kidding me.

It works in NN now, but not in IE!!!

raven_101
03-12-2004, 11:27 AM
I used a script to tell which browser it was using and put an if then else command in, it is all set now.

thanks a lot for the help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum