Welcome to WebmasterWorld Guest from 54.145.167.92

Forum Moderators: open

Message Too Old, No Replies

Refreshing a page when closing a popup

Close the popup and the page that opened it refreshes

   
10:37 am on Jul 28, 2008 (gmt 0)

5+ Year Member



Hi JSers !

I don't know much, if anything, in Javascript but I'm facing a problem I'm sure JS could solve. I have a page with a link that, when clicked, opens a popup with :


OnClick=window.open

Now, that popup performs its action and ends. The popup stays there and now offers a link to click in order to close it with :


javascript:window.close()

What I'd want to do is to send a "message", or some sort of trigger from the popup to the main page so that when the popup closes, the main page that called it refreshes itself.

Can Javascript do that ? And if yes, how would you go about it ?

Thanks for your help

jerome.

10:23 am on Jul 30, 2008 (gmt 0)

10+ Year Member



On the first instance i'd sugest to try
opener.reload()
from the popup, but the decent solution is to make a callback function on the main window (say myReload()), which only reloads the page itself. Within the popup you can make a function like below, and call this function whenever you want to close that window.

function closeMe() {
if (opener && opener.myReload) opener.myReload();
window.close();
}