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

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

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <table border="1" width="100%">
        <tr>
            <td width="100%"><iframe src="iframe1.html" name="aa"></iframe></td>
        </tr>
        <tr>
            <td width="100%"><iframe src="iframe2.html" name="bb"></iframe></td>
        </tr>
    </table>
</body>
</html>

iframe1.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        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="33333" onclick="aa()">
    </form>
</body>
</html>

iframe2.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</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://www.jb51.net/article/87682.htm

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值