Additional code to enhance script

Discussion in 'HTML & Website Design' started by EcJughead, Aug 26, 2006.

  1. #1
    Using the following script:

    <script type="text/javascript">
    var iframe_urls = new Array("iframe1.html", "iframe2.html", "iframe3.html", "iframe4.html", "iframe5.html");
    var random_number = parseInt(Math.random() * iframe_urls.length);

    document.write('<iframe frameborder="0" width="200" height="200" src="' + iframe_urls[random_number] + '">Your browser doesn\'t support iframes.</iframe>');
    </script>

    Instead of "random", how can I incorporate a fade in feature or even having buttons outside the iframe to change the html file within it?
     
    EcJughead, Aug 26, 2006 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    instead of Math.random() just start with the beginning of the Array to the End of array and repeat (if that is waht you are trying to say)

    var max_num = iframe_urls.length - 1;
    var min_num = 0;

    //Increment counter;
    counter++;

    then you can do a setInterval and have it every 5 seconds load a new iframed url with iframe_urls[counter];

    Hope this helps :)
     
    ccoonen, Aug 26, 2006 IP
  3. EcJughead

    EcJughead Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I was curious about adding two features:

    1. A fade in (or other) effect
    2. a button on the main page that onClick refreshes the iframe to a specific url

    Thoughts?
     
    EcJughead, Aug 27, 2006 IP