views:

147

answers:

2

I have a page which has an Iframe. In that Iframe, there are six iframes. When I use

window.onload

or

document.observe(window, 'load', func) // of PrototypeJs,

does it mean that all the contents of Iframe and the other 6 iframes' content have been loaded?

If the answer is not, then how can I be sure that all my iframes content have been loaded.

[The iframes inside the iframe does not have any src. I am filling those Iframes from database content.]

Thanks.

+2  A: 

Resources in iframes/frames live in their own context and you can´t use window.onload in the parent document. Every document in the frames need to tell the parent document that they have loaded.

One way to do this is have isLoaded flags in the parent document set to a falsy value and a window.onload event in every child document setting their isLoaded flag to truthy. Having a setInterval in the parent document checking these flags and once all are set do what you want.

There are probably a million better solutions ^^ I just suggest a rough blueprint.

anddoutoi
Excellent idea. But as I have said that six iframes under the one, does not have src attribute value. In that case, can i set the onload event?
Hoque
If the iframes don´t have a src the window.onload event will fire as soon as all linked resources are downloaded. I guess you then set the src of the iframes in the window.onload event or?
anddoutoi
+1 thanks, like your idea too :)
Peter Perháč
+2  A: 

Why, you can always implement a little counter in javascript and then have each individual iframe notify the parent frame when it's done loading. the counter, once all six frames have shouted they're ready, can do whatever you would want to do in onload. should not be too difficult, although maybe there are more proper ways of doing this. let's see what the others have got for you. good luck!

Peter Perháč
Thanks for your quick reply.
Hoque
Your answer also helped me, but when I clicked you as answered, the other person 'check' mark vanishes away. How can I also marked you as answered. Thanks.
Hoque
well, you can only mark one answer as accepted. If you like someone's contribution, just click the up-arrow to give us some rep points :-) I am glad I could help.
Peter Perháč
+1 for same idea ^^
anddoutoi