我的asp.net项目中有两个Web表单,在Web表单编号1中我有一个按钮,我编写此代码以打开Web表单编号2:
Response.Write("<script> var myWindow = window.open('DatePicker.aspx', '', 'width=400, height=500');</script>");
当打开Web表单编号2时,我希望在关闭Web表单编号2时,Web表单编号1刷新,因此我将此代码写在Web表单编号2上:
<script type="text/javascript">
function RefreshParent() {
if (window.opener != null && !window.opener.closed) {
window.opener.location.reload();
window.close(); // ADDED LINE
}
}
window.onbeforeunload = RefreshParent;
</script>
但网页表单1号没有重载,会发生什么?
答案 0 :(得分:0)
试试这个
function RefreshParent() {
if (window.opener != null && !window.opener.closed) {
window.location= "webformnumber1.aspx";
}
}
如果(window.opener!= null&amp;&amp;!window.opener.closed)条件正在执行,请确保您的代码在内部