Open popup and refresh parent page on close popup

ArMaN picture ArMaN · May 29, 2012 · Viewed 350.1k times · Source

I opened a popup window by window.open in JavaScript, i want to refresh parent page when I close this popup window.(onclose event?) how can I do that?

window.open("foo.html","windowName", "width=200,height=200,scrollbars=no");

Answer

Morrison Cole picture Morrison Cole · May 29, 2012

You can access parent window using 'window.opener', so, write something like the following in the child window:

<script>
    window.onunload = refreshParent;
    function refreshParent() {
        window.opener.location.reload();
    }
</script>