?
Solved

need to determine if popup is loaded

Posted on 2007-10-08
5
Medium Priority
?
272 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:sy_geoffrey
  • 2
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1500 total points
ID: 20033788
Seems too much hassle...

In the parent have

var w = null; // make global
function openWin() {
  w=window.open('','windowname'); // get handle of a window named windowname
  // do what you want with handle...
.
.

}



0
 
LVL 4

Expert Comment

by:Russell2566
ID: 20034077
Closing windows won't work out for you well.. Especially if your users are using IE7... If you really want to change data on the fly. I would really recomend using Ajax to build your data on both pages; completly eliminating the need for much of this hassel and page reloads...

Check Out The Yahoo! User Interface Library (YUI) - http://developer.yahoo.com/yui/
0
 
LVL 4

Expert Comment

by:Russell2566
ID: 20034086
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...
0
 

Author Comment

by:sy_geoffrey
ID: 20038283
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.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20038975
So why a "B" grade?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question