我已经找到了一种跨浏览器的方式来以编程方式设置IFrame的innerHTML.(如http://roneiv.wordpress.com/2008/01/18/get-the-content-of-an-iframe-in-javascript-crossbrowser-solution-for-both-ie-and-firefox/) .我已经编写了一些示例代码(如下所示),我可以在Safari和Chrome中使用它,但不能使用Firefox.任何人都可以帮我弄清楚我需要做什么(以便携方式)?
<html>
<body>
<div name=FRAME2div id=FRAME2div style="position:absolute; background-color:blue; color:black; border-color:black;border-width:0; left:100px; top:40px; width:200px; height:200px; overflow:scroll; display:block; " >
</div>
<script type="text/javascript">
document.getElementById("FRAME2div").innerHTML = '<iframe border=0 id=IFRAME2 name=IFRAME2 ></iframe>';
document.getElementById("IFRAME2").contentWindow.document.body.innerHTML = '<html><body><p>NETSCAPE</p></body></html>';
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)