如何在子窗口关闭时刷新父页面?
答案 0 :(得分:5)
你的孩子会有这样的剧本。
<script type="text/javascript">
function refreshParent() {
//re-set the parent url to refresh
//window.opener references the parent page
window.opener.location.href = window.opener.location.href;
}
</script>
[...]
// the onunload event fires when the child page is closed
<body onunload=refreshParent(); >
答案 1 :(得分:0)
尝试使用子窗口中的给定代码:
<强> ASPX:强>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="butColSmall"
onclick="btnCancel_Click" />
<强> ASPX.CS 强>
protected void btnCancel_Click(object sender, EventArgs e)
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "sCancel", "window.opener.location.href = window.opener.location.href;self.close()", true);
}