Javascript examples for DOM HTML Element:IFrame
The contentWindow property returns the Window object generated by an iframe element.
A reference to the window object
The following code shows how to how to change the background color of the document contained in an iframe:
<!DOCTYPE html> <html> <body> <iframe id="myframe" src="http://java2s.com"></iframe> <p id="demo"></p> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w ww . ja va 2s .c o m var x = document.getElementById("myframe"); var y = x.contentDocument; y.body.style.backgroundColor = "red"; } </script> </body> </html>