[JavaScript] 通过JS代码修改iframe页面的背景颜色 →→→→→进入此内容的聊天室

来自 , 2021-01-11, 写在 JavaScript, 查看 174 次.
URL http://www.code666.cn/view/a9b94e2e
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function changeStyle()
  6. {
  7. var x=document.getElementById("myframe");
  8. var y=(x.contentWindow || x.contentDocument);
  9. if (y.document)y=y.document;
  10. y.body.style.backgroundColor="#0000ff";
  11. }
  12. </script>
  13. </head>
  14. <body>
  15.  
  16. <iframe id="myframe" src="demo_iframe.htm">
  17. <p>Your browser does not support iframes.</p>
  18. </iframe>
  19. <br><br>
  20.  
  21. <input type="button" onclick="changeStyle()" value="Change background color">
  22.  
  23. </body>
  24. </html>
  25.  
  26. //javascript/7940

回复 "通过JS代码修改iframe页面的背景颜色"

这儿你可以回复上面这条便签

captcha