• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, I assumed that the pages came from the same webapp/domain. I guess that should've been the first thing to check!
 
rubbery bacon. rubbery tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic