I would like to rotate random banner ads on my website

Discussion in 'Scripts' started by Mrs. Sinner, Jan 4, 2009.

  1. #1
    Can anyone tell me a code to rotate through random banner ads on my site each time a page is refreshed or visited?

    I currently have the following code, which automatically rotates through the banners every few seconds.

    <script type="text/javascript">
    var imgs1 = new Array("[I]myimage1[/I]","[I]myimage2[/I]");
    var lnks1 = new Array("[I]mylink1[/I]","[I]mylink[/I]2");
    var alt1 = new Array("[I]myalt1[/I]","[I]myalt2[/I]");
    var currentAd1 = 0;
    var imgCt1 = 2;
    function cycle1() {
      if (currentAd1 == imgCt1) {
        currentAd1 = 0;
      }
    var banner1 = document.getElementById('adBanner1');
    var link1 = document.getElementById('adLink1');
      banner1.src=imgs1[currentAd1]
      banner1.alt=alt1[currentAd1]
      document.getElementById('adLink1').href=lnks1[currentAd1]
      currentAd1++;
    }
      window.setInterval("cycle1()",10000);
    </script>
    <a href=""[I]mylink1[/I]"" id="adLink1" target="_top">
    <img src="[I]myimage1[/I]" id="adBanner1" border="0" width="728" height="90"></a>
    Code (markup):
    Perhaps there is an adjustment I can make to this code to make it only change on when the page loads or is reloaded? If not, do any of you know a code that would do what I need?

    I've tried PHP codes, but they do not work on my site, so it can't be PHP.

    Thanks for your help.


    **UPDATE**

    Got what I needed.

    For anyone else who needs a code to rotate through random banners each time the page is visited or reloaded, I posted the code in this thread: http://forums.digitalpoint.com/showthread.php?p=10250694#post10250694 .
     
    Mrs. Sinner, Jan 4, 2009 IP