多个iframe间传值同时刷新另一个iframe

default.aspx:

 <div>
     <iframe id="ifrLeft" src="WebForm1.aspx" ></iframe>
    <iframe id="ifrRight" src="WebForm2.aspx" ></iframe>
    </div>

 

WebForm1.aspx

<div>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        <input id="Hidden1" type="hidden"  runat="server"/>       
    </div>

 

        protected void Button1_Click(object sender, EventArgs e)
        {
            Hidden1.Value = "testTrue";
            Response.Write("<script>javascript:window.parent.frames['ifrRight'].location.reload();   </script>");
        }

WebForm2.aspx

<script type="text/javascript">
    function changeFun() {
        var v = window.parent.frames['ifrLeft'].document.getElementById('Hidden1');
        var t = document.getElementById('TextBox1');
    if (v) {
        t.value = v.value;
    }
    }
</script>

 

<div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>

 

 

动态设置iframe地址:location.href=''

你可能感兴趣的:(多个iframe间传值同时刷新另一个iframe)