Web Analytics Made Easy -
StatCounter Banner rotation script - CodingForum

Announcement

Collapse
No announcement yet.

Banner rotation script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Banner rotation script

    hey guys, do any of you know the simpliest code to a banner rotation which switches in a given span of time?

    I use this code:






    <script language="JavaScript">
    <!--

    /*
    Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com)
    Over 200+ free JavaScripts here!
    Updated: 00/04/25
    */

    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages[1]="http://cute-spot.com/site-decor/advert-images/ad-banners/ad-banner1.gif"
    myimages[2]="http://cute-spot.com/site-decor/advert-images/ad-banners/ad-banner2.gif"
    myimages[3]="http://cute-spot.com/site-decor/advert-images/ad-spot2.gif"

    //specify corresponding links below
    var imagelinks=new Array()
    5
    imagelinks[1]="http://rexangel.pixelbee.net"
    imagelinks[2]="http://www.creamycafe.lefteelicious.com"
    imagelinks[3]="http://cute-spot.com/advertising.html"

    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<a href='+'"'+imagelinks[ry]+'" target="_blank"'+'><img src="'+myimages[ry]+'" border=0></a>')
    }
    random_imglink()
    //-->
    </script>
    </body>
    </html>









    but it only shows a different banner every time the page is reloaded, so i put in an automatic page reload on the same page.

    Now my layout is Iframes, and basically, it works fine....

    my problem is, it doesn't only reload that Iframe, but the whole page/window >_<


    I tried googling "automatic page reload script" on google, but i haven't yet met one that's as organized & simple as the code that i am using above.

    thank you.
    MySpace Layouts

  • #2
    Try this
    Code:
    <script type="text/javascript">
    <!--
    
    /*
    Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com)
    Over 200+ free JavaScripts here!
    Updated: 00/04/25
    */
    
    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages[1]="http://cute-spot.com/site-decor/advert-images/ad-banners/ad-banner1.gif"
    myimages[2]="http://cute-spot.com/site-decor/advert-images/ad-banners/ad-banner2.gif"
    myimages[3]="http://cute-spot.com/site-decor/advert-images/ad-spot2.gif"
    
    //specify corresponding links below
    var imagelinks=new Array()
    5
    imagelinks[1]="http://rexangel.pixelbee.net"
    imagelinks[2]="http://www.creamycafe.lefteelicious.com"
    imagelinks[3]="http://cute-spot.com/advertising.html"
    
    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.getElementById('imagerotator').innerHTML='<a href='+'"'+imagelinks[ry]+'" target="_blank"'+'><img src="'+myimages[ry]+'" border=0></a>';
    }
    setInterval("random_imglink()",5000);
    //-->
    </script>
    Place this
    Code:
    <span id="imagerotator"></span>
    wherever you want the images to appear. The script should load a new image every 5 seconds 1000=1 second, and it shouldn't have to reload the page.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment


    • #3
      i love you sooo much! thank you
      MySpace Layouts

      Comment

      Working...
      X