Refreshing Parent window after closing popup

前端 未结 6 863
南方客
南方客 2020-12-11 02:45

I am creating a popup window that goes to hello.html. I want my original (parent page) to reload when i close the popup window (hello.html). I can\'t seem to get it to wor

6条回答
  •  感动是毒
    2020-12-11 03:38

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

提交回复
热议问题