• javascript 子父窗体操作


    father.aspx

    <head runat="server">
        <title></title>
        <script type="text/javascript">
        //---------------------------------------------------
            function OpenWindow() {
                window.open("child.aspx");
            }
            function setValue(m) {    
                document.getElementById("txt_Value").value = m;
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
          <input type="text" name="txt_Value" id="txt_Value" runat="server" />
          <input type="button" name="btn_ShowClose" id="btn_ShowClose" value="按钮" onclick="OpenWindow();" />
          <br />
           <asp:HiddenField ID="HiddenField1" runat="server" />
        </div>
        </form>
    </body>
    </html>

    father.aspx.cs

            protected void Page_Load(object sender, EventArgs e)
            {
                Response.Write("adf" + HiddenField1.Value);
            }

    --------------------------------

    child.aspx

        <title></title>
        <script type="text/javascript">
            function CloseWind() {
                opener.setValue("2");
                window.opener.document.forms(0).submit();
                window.close();

            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">  
            <asp:Button ID="Button2" runat="server" Text="Button"  OnClientClick="CloseWind()"/>
        </form>
    </body>

    child.aspx.cs

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {

                }
                else
                {
                    Response.Write("<script>");
                    Response.Write("function fm_send()");
                    Response.Write("{");
                    Response.Write("window.opener.document.getElementById('HiddenField1').value =1;");
                    Response.Write("window.opener.document.forms(0).submit();");
                    Response.Write("window.close()");
                    Response.Write("}");
                    Response.Write("fm_send()");
                    Response.Write("</script>");
                }
            }

  • 相关阅读:
    理解js中的原型链,prototype与__proto__的关系
    Zepto源码(2016)——Zepto模块(核心模块)
    MySQL增删改查
    ACM典型试题--古代密码(二)
    ACM典型试题--简单的加密算法(一)
    MySQL图文安装配置
    (c语言)二叉树中序线索(数据结构十七)
    (C语言)二叉树层次遍历(数据结构十六)
    Java连接db2数据库(常用数据库连接五)
    java连接oracle数据库(常用数据库连接四)
  • 原文地址:https://www.cnblogs.com/yidianfeng/p/1967646.html
Copyright © 2020-2023  润新知