www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript Image Rotator on Reload

  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Question Javascript Image Rotator on Reload

    I currently have this script to change the image every time the page is reloaded:

    <script type="text/javascript"><!--
    var img = new Array();

    // Add links to the pictures here, duplicate a line and add between the double-quotes
    img.push("ad/ad1.png");
    img.push("ad/ad2.png");

    // How many random pictures you want to display
    var num = 1;

    // The part where the images are randomed and printed to screen
    for(i=0;i<num;i++) {
    rand = Math.floor(Math.random()*img.length);
    document.write("<img src=\"" + img[rand] + "\" />");
    }
    //--></script>

    Problem:
    These are ad images and I'm not very savvy with javascript - how do I get a URL assigned to each individual image in regards to whichever one is loaded at the time? Thanks for your assistance!

  2. #2
    Join Date
    Jun 2010
    Posts
    2
    Figured it out, please close thread.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles