0

I want to refresh my parent window when I close the popup.I could use following

window.opener.location.reload();

But my requirement is slightly different in that I have to write all this code for refreshing the parent page in the parent page itself.

I cannot write a single line of code in the popup.

Thanks,

pcs
  • 1,864
  • 4
  • 25
  • 49
Javid Ahmad
  • 51
  • 1
  • 5

2 Answers2

1

The only way I know is by checking child window status at frequent intervals but this is explained clearly in this question

That said, I don't know if that could be an alternative, but using a lightbox instead of a new window popup would allow you to keep full control on your events as the whole thing stays in the same window.

Most lightbox API's offer that kind of functionality (loading an external site in the lightbox instead of the usual image), using dynamically generated iFrame to display the external site. This solution also have drawbacks (e.g.: frame-busting code on site loaded in lightbox) but can look nicer than a plain old new window...

I've been using Shadowbox on projects for quite some time now and always liked it, but there are plenty of others out there, maybe even better.

Community
  • 1
  • 1
Laurent S.
  • 6,816
  • 2
  • 28
  • 40
0

You need to handle the unload event handler in the pop-up and do the reloading in the main window. In the main window, add JavaScript:

function popUpClosed() {
    window.location.reload();
}

In the pop-up:

window.onunload = function() {
    if (window.opener && !window.opener.closed) {
        window.opener.popUpClosed();
    }
};

So the answer to your question is generally no, if you need your code to work in all browsers, in particular IE.

Vikrant
  • 4,920
  • 17
  • 48
  • 72
  • OP specifies he can't write any code in the popup page. I guess this is an external site he doesn't have access to. Anyway this answer, although correct and elegant, won't help him. – Laurent S. May 04 '15 at 11:22
  • Well thanks for your response but the issue is that I cannot write any code in the popup page. Actually the popup url is address of a page from another project. – Javid Ahmad May 04 '15 at 11:26