Check child window finished loading (without using onLoad ???)

Hi,

   I'm trying to figure out how to verify that a spawned window has finished laoding.
However, I am not writing the page that gets loaded into the child window so I can't just use the onLoad event on that page to trigger something in my window (at least I don't think I can can I ???). The client page is on another domain but I am a trusted client so can access the DOM so I thought that maybe there might be a way to wait for the closing hmtl or body tag ? But I haven't found a way of doing it...
Can anyone help me ??? Thanks,

   Drewbert
drewbert78Asked:
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.

[ fanpages ]IT Services ConsultantCommented:
Hi,

Do you have any control about the contents of the source in the spawned window of the other party's code, or do you need a solution that could be applied to any spawned page?

i.e. could you request changes to the third party code, or is this not feasible?

Thanks for your clarification.

BFN,

fp.
0
drewbert78Author Commented:

Hi,

   well, both really - unfortunately I have no control over the page in question, plus I would like to come up with a generic solution...

   I've found that I acn query "window.document.readyState" which will return the state of the document as "complete" when it's finished loading. However, I haven't found a way of suspending execution in the parent window while polling the child (e.g. every second) until this is set as setTimeout returns before calling itself again so the parent would carry on with it's code. Thus I guess the problem has evolved into the original question, plus "Can I write my own javascript event and event handler so I can fire the event from the funciton polling the child window ?" or "Is there another way to suspend execution indefinitely until some condition is met ?". This might be better explained with some pseudo-code :-

function a()
{
  openChildWindow();
  waitForChildToLoad();

  doOtherSTuff();
}

funciton waitFortWindowToLoad()
{
  if (childWindow.document.readyState != complete) setTimeout(waitForChildToLoad, 1000);
  else return true;
}

The above will return and call doOtherSTuff() straight away irrespective of whether the child has loaded or not... All help greatfully appreciated - hence another 50 points...

  Drewbert
0
[ fanpages ]IT Services ConsultantCommented:
Hi,

The child window could set the value of a variable to a pre-defined setting that could be queried by the parent in a Timer-based loop.  As soon as the value is set as expected then the parent can cease the reinvocation of the Timer and continue as desired.

I have used a similar technique with frame-based windows.

Each .htm in the frames incremented a counter initialized in the Parent and the Parent checked for a value equal to the number of frames expected to load.  For example, 5 frames were defined, and in the Body "OnLoad" event of each of the pages in the frames was code to increment the counter Parent.intFrame_Loaded.  The Parent looped on a Timer event waiting until the intFrame_Loaded variable was set to 5.

Would that approach help?

BFN,

fp.
0

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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

[ fanpages ]IT Services ConsultantCommented:
Hello.

Do you need any further assistance?

Thank you for your reply in any respect.

BFN,

fp.
0
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: fanpages {http:#9934280}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0
drewbert78Author Commented:

   As I stated, I don't actually have control of the client window so setting a variable in the client on the client side is not an option...

   Having done a lot of digging however, I did find that there exists, in the DOM, an attribute window.document.readyState which will be set to "complete" when the window has finished loading. This does however require access to the client DOM which is not allowable cross-domain... Not to be put off by this, I carried on digging and have found a way to gain access to the client DOM by being a trusted client so I can now simply poll the readyState of the client window while it is loading...
0
[ fanpages ]IT Services ConsultantCommented:
Hi again,

Glad you found a solution.

Does this mean that you are now in a position to close this question?

Thanks for your further feedback/comments.

BFN,

fp.
0
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.