如何在关闭PopUp窗口时重新加载父页面?

时间:2013-09-11 08:48:39

标签: c# javascript asp.net vb.net

我在母版页上有一个链接按钮“条款和条件”。当使用点击它时,会使用此代码显示一个弹出窗口

Dim myScript As String

            myScript = "<script>window.open('Terms.aspx?',null,'height=750, width=1024,status= no,resizable= no, scrollbars=yes,toolbar=no,location=no,menubar=no'); </script>"

            ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "pop", myScript, False)

我在弹出窗口页面上有一个接受按钮,我正在关闭此弹出窗口

ClientScript.RegisterStartupScript(GetType(Page), "closePage", "window.close();", True)

问题是我想在弹出窗口关闭后刷新父窗口。我怎样才能实现这一目标? 这不起作用Refreshing Parent window after closing popup

更新

<div style="padding:5px 0;">
      <asp:Button ID="btnAccept" runat="server" Text="Accept"  OnClientClick="Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white; " /> &nbsp;<asp:Button ID="btnReject" runat="server" Text="Reject" OnClientClick="Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white;"/>

</div>

   function Refresh() {
       return confirm('Are you sure?');
       window.onunload = refreshParent;
       function refreshParent() {
           window.opener.location.reload();
       } 
   }

1 个答案:

答案 0 :(得分:0)

您可以使用'window.opener'访问父窗口,因此,在子窗口中写下以下内容:

onunload="window.opener.location.reload();"

或使用此

<script>
    window.onunload = refreshParent;
    function refreshParent() {
    var retVal = confirm("Are you sure ?");
           if( retVal == true ){
            window.opener.location.reload();
          else
            return false;

    }
</script>