javascirpt实现2个iframe之间传值的方法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

javascirpt实现2个iframe之间传值的方法

droidcoffee   2020-05-15 我要评论

本文实例讲述了javascirpt实现2个iframe之间传值的方法。分享给大家供大家参考,具体如下:

index.htm

<body>
 <table border="1" width="100%">
 <tr>
  <td width="100%"><iframe src="iframe1.htm" name="aa"></iframe></td>
 </tr>
 <tr>
  <td width="100%"><iframe src="iframe2.htm" name="bb"></iframe></td>
 </tr>
 </table>
</body>

iframe1.htm

<html>
<title>1</title>
<head>
 <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);
 }
// --></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>

希望本文所述对大家JavaScript程序设计有所帮助。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们