Accessing child frame's elements - The parent document
by salman
HTML
<p>Please wait 5 seconds to allow the iframe to load</p>
<iframe id="iframe1" src="http://jsfiddle.net/salman/USWrV/show/" style="width: 200px; height: 200px;">
JavaScript
function checkFoo() {
alert(document.getElementById("iframe1").contentWindow.foo);
// perform an operation on that document using vanilla JavaScript
document.getElementById("iframe1").contentDocument.getElementsByTagName("p")[0].style.backgroundColor = "#FFCC00";
}
window.setTimeout(checkFoo, 5000);