技术教程 | 经验技巧 | 网络专区 | 安全防线 更多 >>
通过window.top.document.getElementById 切换iframe的内容
2007-12-26 13:59:02  (人气:)
实例:通过window.top.document.getElementById 切换frame的内容
//if1.htm
 
<br /><br />
<a href="#" onclick="abc();" id="cname2">测试</a><br />
<iframe id="eWebEditor1" src="if2.htm" frameborder="0" scrolling="No" width="98%" height="300"></iframe>
<script>
function abc(){
//document.getElementById("eWebEditor1").src="if2.htm";
//parent.body.document
eWebEditor1.document.getElementById("cname3").innerText="if2.htm";
}
</script>
 
//if2.htm
<span id="cname">测试数据</span>
<a href="#" onclick="abc();" id="cname3">测试</a><br />
<script>
function abc(){
//window.top.document.getElementById("eWebEditor1").src="1.asp";
window.top.document.getElementById("cname2").innerText="测试二";
//window.parent.document.getElementById("cname2").innerText="测试二";
}
</script>
评论 】 【 打印 】 【 关闭