Question

I have opened a popup window and trying to refresh the parent window before closing parent window.

Below is my code. I tried using window.top, top.location, etc but nothing working for me!

Any help?

$("#closeit").click(function(){
    opener.location.focus();
    opener.location.reload();
    window.close();
});
Was it helpful?

Solution

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

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

In the pop-up:

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

OTHER TIPS

You need to use the parent object:

window.parent.location.reload()

http://www.w3schools.com/jsref/obj_window.asp

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top