Solved

Notify parent when Iframe is done loading

Posted on 1998-09-08
11
2,015 Views
Last Modified: 2013-12-25
How can a document containing an Iframe be notified when the Iframe is done loading its web page?


Example:  Parent Document

<html>

<head>
<title>Parent Document</title>
</head>

<body>
<Iframe id="Child_Document" src="child_document.htm"> </iframe>
</body>

</html>


I want to notify the Parent Document that the iframe is done loading "child_document.htm" without adding any code (script/HTML) to the "child_document.htm" document.

I can only add code to the Parent Document.

Basically the "child_document.htm" can be any htm file, so I can't add custom code to the "child_document.htm".

Any Ideas?
0
Comment
Question by:Mira060397
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1854855
Mira,

I am not aware of any way to do this.  Putting an onLoad in the IFRAME code line doesn't work.  I think that without editing the child code this will not be possible.  I'll do some checking though just to make sure.

Trevor.

0
 

Expert Comment

by:deans
ID: 1854856
I also had this problem, and the only way I know of fixing it was to put a <SCRIPT FOR=document EVENT=onload>
parent.processIframe();
</SCRIPT>

In the child document. IE has no way of determining when a web page as finished loading.

If it is data coming from the child document maybe you should consider using XML, or data binding.

0
 

Accepted Solution

by:
egerci earned 200 total points
ID: 1854857
Bellow code runs properly both with netcape and IE
when the frames are loaded it appears an alert box. You can easily add any JavaScript function to onLoad Funtion
for example:
<FRAMESET  COLS="21%,*" onLoad="writeOk()">
and write writeOk funtion in JavaScript.
:))


<HTML>
<HEAD>
      <TITLE> </TITLE>
    <META NAME="keywords" CONTENT="">
    <META NAME="description" CONTENT="">
    <META NAME="Author" CONTENT="H.Ali EGERCI(egerci@yahoo.com)">
      <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1254">
      <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-9">
</HEAD>
<!-- frames -->
<FRAMESET  COLS="21%,*" onLoad="alert('OK')">
    <FRAME NAME="lft" SRC="sublft.html" FRAMEBORDER="yes" >
    <FRAME NAME="rgt" SRC="subrgt.html" FRAMEBORDER="yes" >
</FRAMESET>
</HTML>

0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1854858
egerci,

What you have posted is a way to detect when a FRAME finishes loading.  However this question is about detecting when an IFRAME has finished loading.  Unfortunately the same method cannot be applied.

Trevor.


0
 

Author Comment

by:Mira060397
ID: 1854859
Trevor is right.

Is there any other way besides putting code in the child document?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 5

Expert Comment

by:Trevor013097
ID: 1854860
Mira,

You should reject egerci's answer so that other experts can offer a solution.

I don't believe that there is a way to detect an IFRAME's loaded status without putting something in the child window.

Trevor.
0
 

Expert Comment

by:egerci
ID: 1854861
Ok what about this code? It also run :))
<HTML>
<HEAD>
      <TITLE> </TITLE>
    <META NAME="keywords" CONTENT="">
    <META NAME="description" CONTENT="">
    <META NAME="Author" CONTENT="H.Ali EGERCI(egerci@yahoo.com)">
      <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1254">
      <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-9">
</HEAD>
<body onLoad="alert('OK')" >
<Iframe id="Child_Document" src="child_document.htm"> </iframe>
</body>
</HTML>

0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1854862
egerci,

Nice one.  The IFRAME must therefore become part of the parent documents object and all parent document checks must be satisfied by both parent and child.

Why is it time and time again it is something so simple but it takes an Expert to spot it.

Trevor.


0
 

Author Comment

by:Mira060397
ID: 1854863
That could have worked, but my problem is a little more complex than that.

It's because the Child_Document source will change when a user clicks on a button on the Parent_document (for example). The Child source changes but the Parent source does not.  Therefore the parent never triggers its OnLoad event again.  Meaning The Parent doesn't know when the new document in the Child is done loading.
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1854864
Mira,

Now that throws a different light on the matter.  I don't think no matter what you do you will be able to achieve this without setting a flag from the child document.

Trevor.

0
 

Author Comment

by:Mira060397
ID: 1854865
Under most circumstances your answer would have worked.  But for my specific instance, there doesn't seem to be a solution with the current technology.


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now