简体   繁体   中英

How to reload parent page on closing PopUp window?

I have a linkbutton "terms and conditions "on a master page.. when use clicks on it a popup window is displayed usingthis code

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)

I have a accept button on pop up window page on which i am closing this pop up

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

The problem is i want to refresh the parent window once this pop up is closed. How can i achieve this? This did not work Refreshing Parent window after closing popup

UPDATE

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

You can access parent window using 'window.opener', so, write something like the following in the child window:

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

or use this

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

    }
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM