简体   繁体   中英

refresh parent window when closing child window

How can I refresh the parent window when clicking the close button of a child window?

The child window is a pop-up.

To refresh the parent page on close of child window use the following javascript in the popup page and call that using onunload in the popup page.

function refreshParent() 
{
    window.opener.location.reload(true);
}

<body onunload="javascript:refreshParent()">

You can access the parent window using

window.opener

and refresh the parent window using

window.opener.reload()

See window.opener

<body onunload="window.opener.reload();">

If you use this when you close your child window, the parent will be reloaded. window.opener refers to the parent window object.

尝试这个

self.opener.location.reload(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM