Rotate Ad based on time

[Total: 0    Average: 0/5]

This example rotates an ad based on the time mod number of ads.

Body Code:

<script>
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="The Infobay";
  url="/";
  alt="Banner Exchange";
  banner="/js/pic1.gif";
  width="468";
  height="60";
}
if (ad==2)
{
  txt="Phil's MechWarrior2 Page";
  url="/consult/";
  alt="Banner Exchange";
  banner="/js/pic2.gif";
  width="468";
  height="60";
}
if (ad==3) 
{ 
  txt="Banner Exchange";
  url="/js/";
  alt="Banner Exchange";
  banner="/js/pic3.gif";
  width="468";
  height="60"; 
}

document.write('<center>');
document.write('<a target="banner" class=orange href="' + url + '" target="_top" target="banner">');
document.write('<img src="' + banner + '" width=');
document.write(width + ' height=' + height + ' '); 
document.write('alt="' + alt + '" border=1><br></a>'); 
document.write(' ' + txt + ' '); 
document.write('</center>'); 
</script>

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *