我有两个页面,名为“Form_1.html”和“Form_2.html”。
“Form_1.html”是我使用 window.open() 方法打开“Form_2.html”的父窗口。
现在我想要的是,当我在子窗口(“Form_2.html”)中编写 window.close() 时,我希望焦点返回到“Form_1.html”并且父窗口应该得到焕然一新。
我只希望在 javascript 中使用它,因为我无法使用 jquery(因为不允许)。
提前谢谢
最佳答案
你可以使用这个:
function RefreshParent() {
if (window.opener != null && !window.opener.closed) {
window.opener.location.reload();
}
}
window.onbeforeunload = RefreshParent;
您可以在这里找到演示:http://aspsnippets.com/demos/542/
关于javascript - 将焦点从子窗口返回到父窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27958343/