[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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM