Link to home
Start Free TrialLog in
Avatar of drewbert78
drewbert78

asked on

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
Avatar of [ fanpages ]
[ fanpages ]

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.
Avatar of drewbert78

ASKER


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
ASKER CERTIFIED SOLUTION
Avatar of [ fanpages ]
[ fanpages ]

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello.

Do you need any further assistance?

Thank you for your reply in any respect.

BFN,

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

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