Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to refresh the main window once we close the popup

 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Page (Shopping Cart), in that page there is box showing cart items and prices. And also the same page contains one link which is pointing to completely different site(different context).

When the user clicks on that link, one popup window opens and going to that site. Once the user fills the form and submits, it goes to DB and updates the record and finally after we get the confirmation page on the popup, there is a close button on the popup which indicates to close that page.

Generally once we close the popup window it supposed to update the cart items and price, but it doesn't. When we refresh the page, the items are grabing from DB and displaying updated data.

Suppose if the popup window is with in the application, then we can refresh the page easily, but in this case its bit difficult to update page since pop is different site.

How can we do that?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
window.opener.location.reload(true);
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know we need to place this line popup window's javascript, but here the popup window is a different context which we can't access to handle the jsp pages.

So how we can refresh the main page with that line?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web app contexts are moot. If there is a client-side relationship between the windows, Eric's approach will work. If there is not a relationship, there is nothing you can do.
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Bear,

is there any alternate solution to my query? could you please let me know.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not until you explain why you need an alternate solution. Why does Eric's solution not meet your requirements?
 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I 100 % agree Eric's solution works, I already tested with related popup window.

You also told me that if there is no relationship, then that solution won't work. The reason why I asked you is there any alternative.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. No relationship means no control.
 
Pradeep Palat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you do not have control over the code in the external window (like opening a external site in the popup), then you can poll for the status of the popup window and do a self refresh when the popup window is closed.
From main window start a polling routine using setTimeout when the popup is opened, that checks for the popup window's state. If the popup window handle is closed or null then clear the timeout and perform the refresh.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep Palat wrote:then you can poll for the status of the popup window

If there is no relationship between the windows, this is not possible.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic