Problem:
AA.html中有一ID为: content 的文本域(textarea),
BB.html中的一段js来给AA.html中ID为: content 的文本域赋值
solution:
1, main.html
<body>
<iframe ID="AAA" name="AAA" src="AA.html" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:265px;width:814px;"></iframe>
<iframe ID="BBB" name="BBB" src="BB.html" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:265px;width:814px;"></iframe>
</body>
2,AA.html
<body>
<form method="post" name="form1">
<p><textarea rows="5" name="content" id="content" cols="73"></textarea></p>
</form>
</body>
3,BB.html
<body onload='window.parent.AAA.form1.content.value="data from BB";'>
<br>
</body>
AA.html中有一ID为: content 的文本域(textarea),
BB.html中的一段js来给AA.html中ID为: content 的文本域赋值
solution:
1, main.html
<body>
<iframe ID="AAA" name="AAA" src="AA.html" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:265px;width:814px;"></iframe>
<iframe ID="BBB" name="BBB" src="BB.html" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:265px;width:814px;"></iframe>
</body>
2,AA.html
<body>
<form method="post" name="form1">
<p><textarea rows="5" name="content" id="content" cols="73"></textarea></p>
</form>
</body>
3,BB.html
<body onload='window.parent.AAA.form1.content.value="data from BB";'>
<br>
</body>
本文介绍了一个使用HTML与JavaScript实现iframe间通信的例子。通过设置父页面中的iframe引用,可以在不同iframe之间进行数据传递。具体操作是利用BB.html中的JavaScript代码给AA.html中的文本域赋值。
1万+

被折叠的 条评论
为什么被折叠?



