Yes, you can do this if the location of the iframe and the parent page of the same host (same origin policy).
For the browser to allow you to do this, you can use
document.domain = "example.com"
on the parent page and in the iframe. (note that subdomain.example.com and example.com are different)
Dom method for this (parent page in iframe):
document.getElementById("myiframe").contentWindow.document.getElementById("divinframe").innerHTML = "I'm on the inside.";
document.getElementById("myiframe").contentWindow.someFunctionInsideIframe();
contentWindow is the answer and works in most, if not all modern browsers, of course, chrome, ie7 +, etc.
To go the other way (iframe to the parent page):
top.document.getElementById("DivInTopParent")
James
source share