Forum Moderators: open

Message Too Old, No Replies

Testing when an IFRAME has loaded

         

Stark

1:10 am on Dec 23, 2004 (gmt 0)

10+ Year Member



I need to load some content from an external site (that I don't control) into an iframe, but I want to be able to tell once it has finished loading.

Basically, I want to load content from an external page into a hidden iframe in the background and then once it is live set it as viewable. Can anyone point me in the right direction please?

Stark

6:42 pm on Dec 30, 2004 (gmt 0)

10+ Year Member



back to answer my own question in case anyone is interested.

It's fairly simple actually, turns out you can place on onLoad parameter into the iframe definition.

e.g.

<iframe id=myiframe name=iframe src=somepage.html onLoad=some_javascript_function()></iframe>

This works for IE6, and Firefox. However, earlier Opera versions don't seem to support it. For that you need to continually check myiframe.document.readyState. Once the iframe has loaded it is set to "complete".

Hope it helps someone