【问题标题】:Returning focus to the parent window from child window将焦点从子窗口返回到父窗口
【发布时间】:2015-01-15 07:10:13
【问题描述】:

我有两个页面分别称为“Form_1.html”和“Form_2.html”。

  • “Form_1.html”是我使用 window.open() 方法打开“Form_2.html”的父窗口。

  • 现在我想要的是,当我在子窗口(“Form_2.html”)中编写 window.close() 时,我希望焦点返回到“Form_1.html”并且父窗口应该得到刷新了。

  • 我想要它在 javascript 中只是因为我不能使用 jquery(因为它是不允许的)。

提前谢谢你

【问题讨论】:

  • 我在子窗口中的工作完成后写了这个。窗口.close(); window.open("Form_1.html","_self");但是现在如何刷新父页面呢?

标签: javascript html


【解决方案1】:

你可以用这个:

function RefreshParent() {
        if (window.opener != null && !window.opener.closed) {
            window.opener.location.reload();
        }
    }
    window.onbeforeunload = RefreshParent;

你可以在这里找到一个演示:http://aspsnippets.com/demos/542/

【讨论】:

  • 你能再回答我一件类似的事情吗?只关注焦点?
  • 这将刷新您打开子弹出窗口的父窗口。
  • 如何在我的子窗口打开时禁用我的父窗口,然后在子窗口关闭时再次启用它?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-03
  • 1970-01-01
  • 1970-01-01
  • 2014-05-13
相关资源
最近更新 更多