Check if an IFRAME is loaded?

Hello. I need to load a PHP page into an IFRAME (I already have the PHP echo exactly what I need, that's not the question). Whatever is echo'd to that page I need to store in a JavaScript variable. I know I can do this using FRAME.document.body.innerHTML, but there's a problem: On slower internet connections, the frame won't be ready to read from yet.

Is there anyway using JavaScript (or HTML, although I don't think this is possible with just HTML) to check if an IFRAME has completely loaded it's contents?

-IMP2008 ;) :)
IceMetalPunk2008Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bendaltonCommented:
Hi IceMetalPunk2008,
If you have control of the IFRAME contents you can have a <body onload="loaded=true;">
and then have the javascript check for that variable to be true...

my thoughts... if not, as far as I know, in IE at least, you cannot get load events from another frame... soo...  pause/wait/retry...



Cheers!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IceMetalPunk2008Author Commented:
I guess I can do that.... Like have a JavaScript in the parent that has frameloaded=false, then in the IFRAME have <body onLoad="parent.frameloaded=true">


Would this work, or will I have to check the IFRAME's variable's only?

-IMP ;) :)
bendaltonCommented:
I've had mixed luck, theoretically it should work, but i've had issues setting parent variables from other windows... it usually works to read them.. so you could check from the script if the IFRAME's loaded is toggled true...

just my 2cents
IceMetalPunk2008Author Commented:
OK, I'll try it out, and if it works, I'll accept your answer.

-IMP ;) :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.