javascirpt实现2个iframe之间传值的方法
本文实例讲述了javascirpt实现2个iframe之间传值的方法。分享给大家供大家参考,具体如下:
index.htm
<body> <tableborder="1"width="100%"> <tr> <tdwidth="100%"><iframesrc="iframe1.htm"name="aa"></iframe></td> </tr> <tr> <tdwidth="100%"><iframesrc="iframe2.htm"name="bb"></iframe></td> </tr> </table> </body>
iframe1.htm
<html>
<title>1</title>
<head>
<scripttype="text/JavaScript">
<!--
functionaa(){
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>
<formid="a">
<inputid="TextBox1"type="text"id="TextBox1"value="1"/>
<inputid="TextBox2"type="text"id="TextBox2"value="2"/>
<inputid="T"type="button"value="3333333"onclick="aa();"/>
</form>
</body>
</html>
iframe2.htm
<html> <title>2</title> <head></head> <body> <formid="b"> <inputid="TextBox3"type="text"id="TextBox1"value="1231111"/> <inputid="TextBox4"type="text"id="TextBox2"value="123"/> </form> </body> </html>
更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《JavaScript传值操作技巧总结》、《javascript编码操作技巧总结》、《JavaScript中json操作技巧总结》、《JavaScript切换特效与技巧总结》、《JavaScript查找算法技巧总结》、《JavaScript动画特效与技巧汇总》、《JavaScript错误与调试技巧总结》、《JavaScript数据结构与算法技巧总结》、《JavaScript遍历算法与技巧总结》及《JavaScript数学运算用法总结》
希望本文所述对大家JavaScript程序设计有所帮助。