JS l两个 Frame 之间传值

本文通过具体的HTML和JavaScript代码示例展示了如何在两个不同的iframe之间传递文本框的值。主要内容包括设置iframe、定义JavaScript函数以获取和设置文本框的值,并触发相应操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

javascirpt实现2个frame传值

index.htm <body> <table border="1" width="100%"> <tr> <td width="100%"><iframe src="iframe1.htm" mce_src="iframe1.htm" name="aa"></iframe></td> </tr> <tr> <td width="100%"><iframe src="iframe2.htm" mce_src="iframe2.htm" name="bb"></iframe></td> </tr> </table> </body> iframe1.htm <html> <title>1</title> <head> <mce:script type="text/javascript"><!-- function aa(){ parent.frames["bb"].document.all["TextBox3"].value = document.getElementById("TextBox1").value; parent.frames["bb"].document.all["TextBox4"].value = document.getElementById("TextBox2").value; alert(parent.frames["bb"].document.all["TextBox3"].value); alert(parent.frames["bb"].document.all["TextBox4"].value); } // --></mce:script> </head> <body> <form id="a"> <input id="TextBox1" type="text" id="TextBox1" value="1"/> <input id="TextBox2" type="text" id="TextBox2" value="2"/> <input id="T" type="button" value="3333333" onclick="aa();"/> </form> </body> </html> iframe2.htm <html> <title>2</title> <head></head> <body> <form id="b"> <input id="TextBox3" type="text" id="TextBox1" value="1231111"/> <input id="TextBox4" type="text" id="TextBox2" value="123"/> </form> </body> </html> 本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/a9529lty/archive/2008/10/27/3161022.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值