This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes can't get my child window to close and reload the parent. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "can Watch "can New topic
Author

can't get my child window to close and reload the parent.

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I want the following scenario:

1 User clicks on a link
2 Popup window opens.
3 XXXXX - See below.
4 Popup disappears
5 original window reloads.

So I've got the link to pop open the window (1, 2). I've got the code that will work to close the child window and reload the parent (4, 5).

What is not working right now, is 3.
I want a form submission to take place, and after it's done processing, proceed with steps 4,5. I've googled around a bit, and several sites instruct me to use javascript to submit the form, and then proceed with steps 4,5, all from within the popup. The problem with this is, the form might not be processed (server-side) before my first page reloads. I want to be absolutely certain the form has completed processing. So what I've done is made a servlet that does the form processing (3), then outputs the HTML/javascript required to produce steps 4, 5. In this way, I guarantee the main page is not reloaded until it's ready to.

Here is the code:


So , if you create a popup window with nothing but the above... then it works 'perfectly'... step 1,2,4,5 happen all as expected. But when the HTML/javascript above, is produced as the output of a form submission from within the popup, I get an error. On Mozilla, it just sits there with a blank screen. On IE, the error is:
Line: 5
Char: 4
Error: Access is denied

I suppose what's happening is, the result of the form submission is "some other page" and the 'opener' object is not maintained. I thought it would be, because I thought it was a 'window' attribute.

any ideas?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Yeah, off the top of my head I would have expected opener to remain valid since you are only swapping out the document. Oh well...
How about if you submit your form into an invisible iframe? That way the original page, with opener intact would remain across the submission. The response to the submission could alert its parent that it's done, which would trigger the close and reload of the opener. A bit messy, but may work for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Thanks Bear,

That idea scared me a bit. So I looked harder.

This was my problem:
http://www.dannyg.com/ref/jsminifaq.html#q15

I was popping open the child window from the parent's domain, but the response from the servlet came from a subdomain. Since the subdomain was an alias anyways, I set them both the same, and now it works.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Oh, I assumed that the pages came from the same webapp/domain. I guess that should've been the first thing to check!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can't get my child window to close and reload the parent.