关闭弹出窗口后重新加载父页面 [英] Reload parent page after closing popup window

查看:120
本文介绍了关闭弹出窗口后重新加载父页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让用户通过弹出窗口登录.当他们单击指向作为php变量的弹出窗口的链接时,他们可以登录.当窗口关闭时,我希望它重新加载他们最初位于的页面(父页面).

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).

这是signin.php页面上的代码...

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.

推荐答案

要重新加载页面,可以将location属性设置为当前值,如下所示:

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;"

您还可以使用location对象的reload方法:

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

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

这是首选方法.

此外,请参考上一个问题的已接受答案:刷新后的父窗口关闭弹出窗口

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

文档

  • 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

这篇关于关闭弹出窗口后重新加载父页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆