When is popped up window done rendering?

  • Thread starter Christopher Benson-Manica
  • Start date
C

Christopher Benson-Manica

I have a situation where a bit of script needs to pop up another
window, and then call a script in that new window. My conundrum is
that the script should not be called until the new window has rendered
completely. What's the best way for the new window to tell its opener
that it is fully rendered? The thought that occurs to me is having a
script at the bottom of the new window that calls a script in the
openening window that then calls the "real" script in the new window.
The obvious solution (having the new window just call the script
itself) isn't feasible because the opener has the information that the
new window's script needs. Is there a better way to do this? I
apologize if I've explained my situation poorly.
 
W

William Morris

It doesn't truly matter where the script goes. If you want to be sure it
doesn't run until the window has fully loaded its code, put your script at
the end

- Wm
 
R

Randy Webb

Christopher said:
I have a situation where a bit of script needs to pop up another
window, and then call a script in that new window. My conundrum is
that the script should not be called until the new window has rendered
completely. What's the best way for the new window to tell its opener
that it is fully rendered? The thought that occurs to me is having a
script at the bottom of the new window that calls a script in the
openening window that then calls the "real" script in the new window.
The obvious solution (having the new window just call the script
itself) isn't feasible because the opener has the information that the
new window's script needs. Is there a better way to do this? I
apologize if I've explained my situation poorly.

page1 opens page2
page1 wants to call a function in page2
page1 needs to know when page2 gets loaded.

page1:

window.open('page2.html')

page2:
function iAmLoaded(){
window.opener.functionNameInPage1YouWantToRun();
}
window.onload = iAmLoaded;
 
N

Nathan Sweet

In the new window that opens:

<script>
window.onload = function () {
var neededInfo = window.opener.getInfoForNewWindow();
// Use info gotten from parent window here.
}
</script>

Or let the parent window know when the new window is ready:

<script>
window.onload = function () {
window.opener.newWindowIsOpen();
}
</script>

Or you could actually check the status of the new window from the
parent window, but this is going to be more browser specific.

-Nate
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top