문제

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();
});
도움이 되었습니까?

해결책

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

다른 팁

You need to use the parent object:

window.parent.location.reload()

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top