开发者

refresh a parent page when child window is closed

开发者 https://www.devze.com 2023-02-12 03:01 出处:网络
How do I refresh a par开发者_高级运维ent page when its child window is closed?You\'ll have a script like this in the child.

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

精彩评论

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