Refreshing Parent window after closing popup

与世无争的帅哥 提交于 2019-11-28 12:09:05

Subscribe to the unload event in the child window and call the parent window from the child window to notify it is closing!

Edit Added a code sample...

function popupClosing() {
  alert('About to refresh');
  window.location.href = window.location.href;
}

var w = window.open("hello.html","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400");
w.onunload = function () {
  window.parent.popupClosing()
};

Do it like this, after creating the popup monitor its "closed" status property in an interval. But this is added in the parent document:

var pop = window.open("page.html", "popup",
            "width=800,height=500,scrollbars=0,title='popup'");
    pop.focus();

    var monitor = setInterval(function() {

        if (pop.closed) {
            document.location.reaload()
        }

    }, 1000);

Try putting this javascript code in your popup window:

window.onunload = function(){
  window.opener.location.reload();
};

/onunload event will trigger when you close your popup window, and window.opener.location.reload() will reload the source (parent) window./

on click event of popup close function Try...

window.opener.location.reload(true);
ravi shankar

This piece of code works as well if a new window is popped with the window.open feature.

setTimeout(function () { window.opener.location.reload(true); window.close();}, 3000);

Put this script in the header of your popup window:

<script type='text/javascript'>
window.onunload = function(){
window.opener.location.reload();}
</script>

This will reload the parent window when you close the popup.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!