Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IFrame - Page Load in Sequence

Status
Not open for further replies.

NiceArms

Programmer
May 21, 2009
105
GB
Hi guys/Girls,

I am trying to load a list of pages into and Iframe one after the other, without any user interaction.

What I want to happen is: page1 loads into the Iframe then after X seconds page2 will load into the Iframe, then page3 and finally back to page1.

So far I have been working with:

Code:
setTimeout(document.getElementById['frame'].src = "Page2",5000)
within an IF but I cant seem to get it to work!


I will admint I am new to Javascript, so if anyone has a suggestion please feel free to enlighten me :D

/Nice
 
I figured it out!

there is goner be a better way of doing this but this works and it also resizes the Iframes height :D

Code:
<html>
<HEAD>
<title> A Page</title>

</HEAD>
<body>

<script type="text/javascript">
    //Load X
    function page1()
    {
        document.getElementById("frame").src = "Page1"
        setTimeout("page2()",3000)
    }
    
    //load X
    function page2()
    {
        document.getElementById("frame").src = "page2"
        setTimeout("page3()",3000)
    }
        //load X
    function page3()
    {
        document.getElementById("frame").src = "page3"
        setTimeout("page4()",3000)
    }
        //load X
    function page4()
    {
        document.getElementById("frame").src = "page4"
        setTimeout("page5()",3000)
    }
        //load X
    function page5()
    {
        document.getElementById("frame").src = "Page5"
        setTimeout("page1()",3000)
    }
</script>
<iframe id="frame" src="Page1" width="100%" onload="resizeIframe" frameborder="no"> </iframe>
<script type="text/javascript">
function resizeIframe() {
                        var height = document.documentElement.clientHeight;
                        height -= document.getElementById("frame").offsetTop;
                        height -= 20; 
                        document.getElementById("frame").style.height = height +"px";
                        };
document.getElementById("frame").onload = resizeIframe;
window.onresize = resizeIframe;
setTimeout("page2()",3000)
</script>
</body>
</html>

/Nice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top