PC.
PC.

Reputation: 481

Parent window of a popup not reloading

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();
});

Upvotes: 2

Views: 1068

Answers (2)

Talha
Talha

Reputation: 19282

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();
    }
};

Upvotes: 4

Emery King
Emery King

Reputation: 3534

You need to use the parent object:

window.parent.location.reload()

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

Upvotes: -1

Related Questions