PDA

View Full Version : How can we random load page to iframe?



kenneth
03-06-2005, 06:18 PM
Script: Iframe SSI script II http://www.dynamicdrive.com/dynamicindex17/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?

ddadmin
03-09-2005, 10:24 PM
Try changing the <iframe> HTML code so it instead reads:


<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.

kenneth
03-10-2005, 02:06 AM
:D

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