Solved

Notify parent when Iframe is done loading

Posted on 1998-09-08
11
2,048 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

807 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