1 Reply Latest reply on Jun 8, 2008 9:42 PM by Nick Barling

    Auto Change BAnner Graphic Daily / Weekly

      I am sure this could be answered easily if I was good (or even Current) with scripting- alas I am not… this question is a from a video film guy- sorry.

      I am looking to change a home page and splash page image (jpg & or gif) and also some swf animations.
      Simply put, i have 5 main 'images' that appear on my main splash or home page...i would like to have them automatically switch daily or every other day, or for that matter every hour… just something that was longer than an ‘animated’ gif, and didn’t require me to change it manually.

      I would also like the same to occur with a series of flash swf animations.
        • 1. Re: Auto Change BAnner Graphic Daily / Weekly
          Nick Barling Level 1
          You need scripting for this. I suggest JavaScript.

          Set up your image and/or swf files with similar names except for the last part of the file name before the file extension. For example if you are switching images you could name them img_set_1.png, img_set_2.png, etc. Name as many images as you want to switch.

          Then you need a function to generate random, or precise, sequences that reference the images in your collection. Something like this:

          function randomGenerator( lowerImg, higherImg) {
          return math.floor(Math.random() * (higherImg - lowerImg +1)) + lowerImg;

          This will generate a whole integer (number) between the lowest img number and the highest img number in your collection.

          Add the function in the <head> of your document or external js file and call it onLoad or something like document.write ('<img src="img_set_' + randomGenerator(1, 9) + '.png" />');

          Put this second code snippet in the body of the page or within the div etc where you house the images. The values 1 and 9 are the numbers of the first and last images in your collection. If have more than 9 just add the correct value range to pass to the function.

          You can hook this type of function up to a timer for day, hour, minute, delivery or use as is for a random img load on each page refresh.

          You can also do a Web search for JavaScript img switching and if you add 'DOM' to your search you can also avoid embedding javascripting in your html, which is a more semantic and forward compliant way of using scripting.