Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <iframe id="myframe" src="demo_iframe.html"></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.contentDocument; y.body.style.backgroundColor = "red"; } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_contentdocument2 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:32:06 GMT --> </html>
Result:
Try it Yourself - © w3schools.com