SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Check onload from IFrame

    Hi,

    i have a Page with a countdown timer and a IFrame.
    In this Iframe i open, when the TImer is 0, a PHP Script that respond random Urls. So the result is like a diashow of different pages.

    Now the Prob is, when the speed is slow the Iframe is not finished loaded the timer is 0 and starts to open another url.

    How can i check if the IFrame is full loaded and after that I start my Timer to count?

    Thanks chris

    To see what i mean have a look at:
    http://www.guruk.com/go/jump-auto15.htm

    (you can also answer to : c-a-m@arcor.de)

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    call a function on your main page from the iframe page

    <body onload="parent.SetTimer();" >


    if the iframe page is to be viewed ouside the IFRAME


    function CheckParent(){

    if (parent.location.match('MyPage.htm'){
    parent.SetTimer();
    }

    }


    example on

    http://homepage.ntlworld.com/vwphill...rchForText.htm

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Onload from IFrame

    Hi, thanks

    but I can not put anything in the content of the iFrame. Because some of them are not mine. Thats the Prob.

    I have to check from outside of this Iframe, in my parent WIndow if the content inside the IFrame is fully loaded and then I like to start my Counter. like:

    (not working script for the Mainwindow, only for understanding, im not a js programmer)

    If id.iframe.onload = true then startTimer.

  4. #4
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I might suggest you use the onload attribute of the iframe's element tag to trigger your function. To place an event handler on the iframe element, you'll have to wait until the main page has finished loading, in order to apply it. That might cause timing problems.

    Here's an example of that approach, just replace the alert('') with your function name:

    Code:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <title>Untitled</title>
      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
      </head>
      <body>
      <iframe id="ifOne" onload="alert('');" src="your_file_1.htm"></iframe>
      <a href="#" onclick="document.getElementById('ifOne').src='your_file_2.htm';">file</a>
      </body>
      </html>
    Last edited by JVLB; Feb 15, 2005 at 11:26.


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
  •