Julian Dormon
Julian Dormon

Reputation: 1779

How can my iFrame know when the page is loaded within it?

I have a web page which loads an iFrame into itself dynamically via javascript. This was causing a white flash in IE and I was able to solve the flash problem using the following attributes on the iFrame:

<iframe style="visibility:hidden;" onload="this.style.visibility = 'visible';" src="../examples/inlineframes1.html" > </iframe>

Once the frame is loaded, I load other pages into the frame using target="frameName" - not by dynamically changing the source of the iFrame. This, however, causes yet another white flash.

To make matters more interesting, the pages that load in the iFrame are cross-domain.

How can the iFrame in the parent know when the page has completed loading within the iFrame without resulting to postMessage from within the iFrame document?

In other words, is there some kind of event IN THE PARENT that is fired when the iFrame's document loads?

If there is, then I could make the iFrame invisible on the "a" tag's click event, and make it visible again when the iFrame's document has loaded, thereby avoiding the white flash.

Upvotes: 2

Views: 82

Answers (0)

Related Questions