rdcody
07-09-2003, 08:40 PM
Hey All,
I found the banner rotator code below somewhere today. It
works very well, except I would like it to rotate the banners in
the order they are listed in, instead of random.
I plan on having 10 or 12 banners eventually. Would
someone please tell me how to do this? I'm new to
Javascript, but willing to learn.
Thanks in advance,
Ron
*******************************
<!-- Begin
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="MySite";
url="http://www.mysite.com";
alt="banner1";
banner="images/banner1.gif";
width="468";
height="60";
}
if (ad==2) {
txt="MySite2";
url="http://www.mysite.com";
alt="banner2";
banner="images/banner2.gif";
width="468";
height="60";
}
if (ad==3) {
txt="MySite3";
url="http://www.mysite.com";
alt="banner3";
banner="images/banner3.gif";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_new\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
I found the banner rotator code below somewhere today. It
works very well, except I would like it to rotate the banners in
the order they are listed in, instead of random.
I plan on having 10 or 12 banners eventually. Would
someone please tell me how to do this? I'm new to
Javascript, but willing to learn.
Thanks in advance,
Ron
*******************************
<!-- Begin
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="MySite";
url="http://www.mysite.com";
alt="banner1";
banner="images/banner1.gif";
width="468";
height="60";
}
if (ad==2) {
txt="MySite2";
url="http://www.mysite.com";
alt="banner2";
banner="images/banner2.gif";
width="468";
height="60";
}
if (ad==3) {
txt="MySite3";
url="http://www.mysite.com";
alt="banner3";
banner="images/banner3.gif";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_new\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->