1 Reply Latest reply on Mar 4, 2010 10:09 AM by Nancy OShea

    Cycle pictures upon refresh

    SC south paw

      Hello, A small group of us are making a website for a non-profit for class and the client would like the main picture on the homepage to change everytime the page is refreshed. What would be the best way of doing this and can anyone point me in the right direction? Example: http://www.spfldcol.edu/

       

      Thank you.

        • 1. Re: Cycle pictures upon refresh
          Nancy OShea Adobe Community Professional & MVP

          You need a randomizer script.  Paste the following javascript code between the <head> and </head> tags of your HTML document.

           

          <script type="text/javascript">
          
          <!--//Random Banner image on Page Reload 
          
          //store the images in array below
          
          images = new Array(5);
          images[0] = "<a href='http://www.example.com'><img src='path/some_image.gif' width='XX' height='XX' alt='some description' </a>";
          images[1] = "<a href='http://www.example.com'><img src='path/some_image.gif' width='XX' height='XX' alt='some description' </a>";
          images[2] = "<a href='http://www.example.com'><img src='path/some_image.gif' width='XX' height='XX' alt='some description' </a>";
          images[3] = "<a href='http://www.example.com'><img src='path/some_image.gif' width='XX' height='XX' alt='some description' </a>";
          images[4] = "<a href='http://www.example.com'><img src='path/some_image.gif' width='XX' height='XX' alt='some description' </a>";
          index = Math.floor(Math.random() * images.length);
          document.write(images[index]);
          //done
          // -->
          </script>
          

           

          Change URL, path/image name, height='XX', width='XX' and alt='text' values to match your own links and images.

          HINT: The more images you add to your array, the more "random" your results will be.

           

          Nancy O.
          Alt-Web Design & Publishing
          Web | Graphics | Print | Media  Specialists
          http://alt-web.com/
          http://twitter.com/altweb
          http://alt-web.blogspot.com