Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <iframe id="myframe" src="demo_iframe.htm"></iframe> <p>Click the button to change the background color of the document contained in the iframe.</p> <p id="demo"></p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.getElementById("myframe"); var y = (x.contentWindow || x.contentDocument); if (y.document)y = y.document; y.body.style.backgroundColor = "red"; } </script> </body> </html>