sy_geoffrey
asked on
need to determine if popup is loaded
Here's the situation,
I have a window(lets call this the parent window) which displays a set of images. The user can popup a window(child window) to get a better display of the images. Now, the user has an option to close the parent window and open another one(this will become the new parent window) to display another set of images without closing the child window. With this, the child window must also be refreshed in order to load the same set of images. The thing is, these 2 windows must be synchronized, so i need to change the reference of the parent in the child window. Im doing something like this:
// in the parent window
var win = window.open(url,name);
win.setParent(window);
//in the child window
var parentWindow = null;
function setParent(win){
parentWindow = win;
}
The code works fine.. BUT the problem is when the child window takes long time to refresh, the parentWindow becomes null. I think that's because win.setParent(window) has been executed while child window is still loading. Obviously, i must call setParent() right after the child window is finish loading. So I've tried something like this in the parent window:
var win = window.open(url,name);
win.document.body.onload = childOnload;
function childOnload(){
win.setParent(window);
}
But this code doesn't seem to work. Is there any other way to determine if popup window has been loaded?Or am I missing something on that code? Btw, I've also tried win.onload = childOnload; and didn't work.
I have a window(lets call this the parent window) which displays a set of images. The user can popup a window(child window) to get a better display of the images. Now, the user has an option to close the parent window and open another one(this will become the new parent window) to display another set of images without closing the child window. With this, the child window must also be refreshed in order to load the same set of images. The thing is, these 2 windows must be synchronized, so i need to change the reference of the parent in the child window. Im doing something like this:
// in the parent window
var win = window.open(url,name);
win.setParent(window);
//in the child window
var parentWindow = null;
function setParent(win){
parentWindow = win;
}
The code works fine.. BUT the problem is when the child window takes long time to refresh, the parentWindow becomes null. I think that's because win.setParent(window) has been executed while child window is still loading. Obviously, i must call setParent() right after the child window is finish loading. So I've tried something like this in the parent window:
var win = window.open(url,name);
win.document.body.onload = childOnload;
function childOnload(){
win.setParent(window);
}
But this code doesn't seem to work. Is there any other way to determine if popup window has been loaded?Or am I missing something on that code? Btw, I've also tried win.onload = childOnload; and didn't work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could take it a step further and do what I would prefer and not do a pop-up window at all. But instead populate a div on the pag with absolute positioning that you display/hide on command that is on top of everything else... Doing a psuedo pop-up without all the problems of multiple windows...
ASKER
thanks mp...
your solution really worked.. there is no need to refresh the child window, i can change the reference of the parent in the child with you solution.
thanks a lot.
your solution really worked.. there is no need to refresh the child window, i can change the reference of the parent in the child with you solution.
thanks a lot.
So why a "B" grade?
Check Out The Yahoo! User Interface Library (YUI) - http://developer.yahoo.com/yui/