Results 1 to 3 of 3

Thread: How can we random load page to iframe?

  1. #1
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How can we random load page to iframe?

    Script: Iframe SSI script II http://www.dynamicdrive.com/dynamici...iframessi2.htm

    thank you so much and I love this script. but is there anyway to change it so that we can load a random page instead of "external.htm" only?

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Try changing the <iframe> HTML code so it instead reads:

    Code:
    <iframe id="myframe" src="" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>
    
    <script type="text/javascript">
    
    var iframeurls=new Array()
    //specify random URLs below.
    iframeurls[1]="test.htm"
    iframeurls[2]="test2.htm"
    iframeurls[3]="test3.htm"
    
    var ry=Math.floor(Math.random()*iframeurls.length)
    document.getElementById("myframe").src=iframeurls[ry]
    
    </script>
    This should work, although not field tested yet.

  3. #3
    Join Date
    Mar 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default



    Great thanks! It works. Only that I have change the array to start with [0] then everything works!

Bookmarks

Posting Permissions

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