www.webdeveloper.com
Results 1 to 5 of 5

Thread: onload executing too soon

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Posts
    23

    onload executing too soon

    I am working on a downloader script and need to load html, get required elements and act accordingly. My probelm is onload for an iFrame is executing too early, and the html is emtpy. As I understand it, this is the way onload is supposed to act and the usual solution is to put an onload statement on the target page, but I don't have any control over the target URL. So I also tried a setTimeout(parseHTL_function_here). But the same thing happens, empty html, it seems the setTimeout also prevents html loading in background. If I put an alert just inside the parseHTL_function and wait a few seconds before clicking ok , the script works, html intact.

    So the basic question is: How can I wait until an iFrame's content is fully loaded before acting on it?

    Any ideas would be greatly appreciated,
    Todd

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Does the document loaded in the iframe belong to the same domain as the parent? If not, there is nothing you can do, as there is no way to establish a cross-domain javascript relationship, for obvious security reasons.
    Last edited by Kor; 03-08-2010 at 02:31 AM.

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    set an onload event on the iframe's document...

  4. #4
    Join Date
    Jun 2009
    Posts
    23
    I don't have control over the document going into the iFrame, it's not my doc. Unless I can add it after it is loaded in the iFrame? Is that possible?

    Todd

  5. #5
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Quote Originally Posted by maddogandnoriko View Post
    I don't have control over the document going into the iFrame, it's not my doc. Unless I can add it after it is loaded in the iFrame? Is that possible?

    Todd
    like kor said, if the doc is on another server, it's out of your reach.
    if it is on your domain but you can't change it, ypu can use javascript to find the iframe's window, and add a load event to it or manipulate a loaded page directly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles