[JavaScript]iframe的contentWindow
HTMLIFrameElement.contentWindow返回的是HTMLIFrameElement类型元素的window对象
通过此对象可以修改iframe实体内的window行为
<iframe id="fr1" width="200" height="200" ></iframe> <script> var theDoc = document.getElementById('fr1').contentWindow; //theDoc.style.display = "block"; //theDoc.document.open(); //会自动打开 //theDoc.document.designMode = "on"; //会自动打开 theDoc.document.write('<html><head>'); //theDoc.document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'); theDoc.document.write('</head><body width="100%" contentEditable=true style="padding:0;margin:0; overflow:hidden;" mce_style="padding:0;margin:0; overflow:hidden;">'); theDoc.document.write("lfasjdfkjalsejioruw fskdjfla;sjdkjfsahgasjdla;kjeioujrfhfaksdjfjal;skdjfhgsadlkfjla"); theDoc.document.write('</body></html>'); theDoc.document.body.contentEditable="false"; //要显示关闭可以编辑状态,不然内容是可以编辑的 </script>