File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes JS: closing popup from parent during onload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JS: closing popup from parent during onload" Watch "JS: closing popup from parent during onload" New topic

JS: closing popup from parent during onload

Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178

I'd like to close a popup from the parent window after the parent window does a submit. Because of several constraints I'd like to do this in the parent's onload functions. Well, my implementations doesn't work and I'd like to get some input from your:

the parent contains:

openMyWindow is called from a button.

The popup contains:

exitForm is called as a button's onclick fuction. My problem is that after returning to the parent, the searchWindow is null, so it seems as if the global variable is lost somehow. Any idea what's wrong? I'm staring at this for hours but can't find my mistake.

EDIT: added CODE tags
[ July 08, 2008: Message edited by: Mike Himstead ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60765

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
If you submit the parent, you destroy the window object that holds the reference to the pop up window. Therefore when the parent reloads, it can not create the reference back to the child.

Mike Himstead
Ranch Hand

Joined: Apr 12, 2006
Posts: 178
Duh, I thought I put it in CODE tags, sorry for that, I added them now.

Thanks for the answer, that's it.
It is sorta covered in the JavaRanch Style Guide.
subject: JS: closing popup from parent during onload
Similar Threads
Popup Question
Communicate from a Popup Window back to the Parent Window
Check if popup window is already open from parent window?
Close main window from popup window
post forms and window.reload()