日期:2014-05-16  浏览次数:20347 次

请问:如何向iframe里写html?
主页面
<div   id= "father ">
</div>

iframe里有
<div   id= 'son '>
</div>


我用下面写方法:
document.iframe.son.innerHTML=father.innerHTML;
报错,说老找不到son这个对象;


请教!谢谢!


------解决方案--------------------
document.frames( "father ").document.getElementById( "son ").innerHTML=father.innerHTML;


============没有测试。
------解决方案--------------------
<html>
<head>
<title> </title>
</head>
<body>
<div id= "father ">
<font size= "12 "> Testing </font>
</div>
<button onclick= "window.frames[0].document.getElementById( 'son ').innerHTML=window.document.getElementById( 'father ').innerHTML "> Test </button>
<iframe src= "about: <div id= 'son '> sss </div> "> </iframe>
</body>
</html>
------解决方案--------------------
window.iframes[ "a "].document.getElementById( "son ")
a为iframe的id