Reload parent page after closing popup window

本秂侑毒 提交于 2019-12-01 07:28:39

问题


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.


回答1:


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

  • window.location on MDN - https://developer.mozilla.org/en/DOM/window.location
  • window.opener on MDN - https://developer.mozilla.org/Talk:en/DOM/window.opener



回答2:


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

It works well in all browsers.



来源:https://stackoverflow.com/questions/11404507/reload-parent-page-after-closing-popup-window

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