PDA

View Full Version : JavaScript Rolling Ads



Rui
10 May 2009, 02:23 AM
Hi,
I've got rolling ads set up on my site using JavaScript to change the ad image every few seconds. I'm trying to make each ad image a link to a different link and can't get it to work. Any ideas a would be great...

Here is the JavaScript code to change the ads:


FirstPart = '<img name="ad" src="images/ad/random/';
LastPart = '.jpg" height="450" width="90">';

function printImage() {
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
document.write(FirstPart + r + LastPart);
}


//////////////////rolling ad script_1/////////////
var images = new Array();
images[1]="images/ad/random/1.gif"
images[2]="images/ad/random/2.gif"
images[3]="images/ad/random/3.gif"
images[4]="images/ad/random/4.gif"

var banIndex = Math.ceil(Math.random() * NumberOfImagesToRotate);
function adChange() {

banIndex++
if(banIndex >= 5)
{
banIndex = 1;
}

document.ad.src = images[banIndex];

setTimeout("adChange()", 10000);
}//end ad change