我尝试了以下 Javascript 代码,尝试从子窗口重新加载父窗口而不关闭子窗口。
<script type="text/javascript">
function refParent () {
if (window != null) {
alert('Not null');
window.opener.reload();
}
else {
alert('null');
}
}
</script>
然后在 HTML 代码中我有以下内容:
<a href="javascript:void(0);" onclick="refParent();">refresh</a>
我确实看到Javascript函数被触发并且窗口不为空,但父页面似乎没有刷新。
有没有办法在不关闭子窗口的情况下刷新父页面?
PS:我希望能够通过表单提交来做到这一点,用户在子窗口中看到表单提交的结果,但父窗口会刷新。因此该事件将发生在表单提交上,而不是单击超链接上。
最佳答案
function refParent(){
window.opener.location.reload();
}
关于javascript - 在Javascript中,如何在不关闭子窗口的情况下从子窗口刷新父窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53638563/