简体   繁体   中英

Reload parent page after closing popup window

I am trying to have the user sign in through a popup window. When they click the link to the popup window which is a php variable they can sign in. When the window closes I want it to reload the page they were originally on (the parent page).

Here is the code on the signin.php page...

<body onunload="opener.location=('')">

But all this does is make the sign in page become the page the user was on. I think I need to put something in the parentheses, but I can't figure out what goes there.

To reload a page, you can set the location property as the current value, like this:

window.location = window.location;

So for your case, you would use, literally:

onunload="window.opener.location = window.opener.location;"

You can also use the reload method of the location object:

onunload="window.opener.location.reload();"

This is the preferred method.

Also, please refer to the accepted answer for your previous question: Refreshing Parent window after closing popup

Documentation

echo '<script>window.opener.location.reload()</script>';
echo '<script>self.close()</script>';

It works well in all browsers.

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