vb.net 如何在关闭弹出窗口时重新加载父页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18736603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 15:02:09  来源:igfitidea点击:

How to reload parent page on closing PopUp window?

c#javascriptasp.netvb.net

提问by SamuraiHyman

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

采纳答案by Sain Pradeep

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

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

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>