Click to See Complete Forum and Search --> : Script help


scroush
08-20-2003, 10:20 PM
Hey guys I'm currently using the script to display banners on my forums but I would like for the to rotate every 10 or seconds, please help

Thanks
Carlos

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="The Number 1 Mustangs Speed Shop";
url="http://www.need-4-speed.com";
alt="need-4-speed";
banner="http://www.modernmustangs-na.com/banners/banner3.gif";
width="468";
height="60";
}
if (ad==2) {
txt="Your # 1 Source For Mustang Advertising!";
url="http://www.ponytrader.com";
alt="Pony Trader";
banner="http://www.modernmustangs-na.com/banners/ponytrader.jpg";
width="468";
height="60";
}
if (ad==3) {
txt="Complete Car Care";
url="http://www.tampaautoservice.com";
alt="Tampa Auto Service";
banner="http://www.modernmustangs-na.com/banners/tampaauto.gif";
width="468";
height="60";
}
if (ad==4) {
txt="Serving all Florida Homeowners!";
url="http://www.lendinghandmortgage.com/";
alt="Lending Hand Mortgage";
banner="http://www.modernmustangs-na.com/banners/lending.gif";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
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 -->
</SCRIPT>

Exuro
08-21-2003, 01:24 AM
Okay, here's what I came up with:


<html>
<head>
<script type="text/javascript">
<!-- Begin
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
function getAd() {
ad +=1;
if (ad > how_many_ads) {
ad=1;
}
if (ad==1) {
txt="The Number 1 Mustangs Speed Shop";
url="http://www.need-4-speed.com";
alt="need-4-speed";
banner="http://www.modernmustangs-na.com/banners/banner3.gif";
width="468";
height="60";
}
if (ad==2) {
txt="Your # 1 Source For Mustang Advertising!";
url="http://www.ponytrader.com";
alt="Pony Trader";
banner="http://www.modernmustangs-na.com/banners/ponytrader.jpg";
width="468";
height="60";
}
if (ad==3) {
txt="Complete Car Care";
url="http://www.tampaautoservice.com";
alt="Tampa Auto Service";
banner="http://www.modernmustangs-na.com/banners/tampaauto.gif";
width="468";
height="60";
}
if (ad==4) {
txt="Serving all Florida Homeowners!";
url="http://www.lendinghandmortgage.com/";
alt="Lending Hand Mortgage";
banner="http://www.modernmustangs-na.com/banners/lending.gif";
width="468";
height="60";
}
document.getElementById('adArea').innerHTML = '<a href=\"' + url + '\" target=\"_top\">' + '<img src=\"' + banner + '\" width=' + width + ' height=' + height + ' alt=\"' + alt + '\" border=0><br><small>' + txt + '</small></a>';
setTimeout("getAd();",20000);
}
// End -->
</script>
</head>
<body onload="getAd();">
<div id="adArea" align="center"></div>
</body>
</html>

That bolded 20000 up there is the number of miliseconds between ad rotations. So if you want it longer, make it bigger, and if you want it shorter, make it smaller. Anyway, hope that helps!

scroush
08-21-2003, 08:48 PM
Hey thanks is working.

Carlos