开发者

refresh a parent page when child window is closed

How do I refresh a par开发者_高级运维ent page when its child window is closed?


You'll have a script like this in the child.

<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(); >


Try with the given code in child window:

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);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜