I've spent probably a month researching the internet on this issue and have yet to find the answer to this. My code does the following (all Javascript).
Let's say I have a test.html on mydomain.com
Very first thing in head section i set document.domain = 'mydomain.com';
Then, dynamically create iframe, set src to "subdomain.mydomain.com/test2.html"
Append iframe to DOM
subdomain.mydomain.com/test2.html: very first thing in head section: document.domain = 'mydomain.com';
test2.html has on_dom_ready event that tries to communicate with parent via window.parent
Works in all browser. even in IE6! The only problem is: when I refresh the page in IE, I get the access denied error.
The only way I can get rid of this error is to wait 12 seconds before calling window.parent. Not even 5 seconds help, I literarely have to wait 12 seconds. It makes no sense to me.
Anyone has any experience with this?
It's because the onload event in the parent frame isn't triggered yet and so the DOM isn't completely built. Here's a kludge that will scan for a div at an interval until it is present, without blowing up:
var minmax_SCANDELAY= 500;
var minmax_scanner;
function minmax_scan() {
if (!window.parent.document.getElementById('content')) return;
window.clearInterval(minmax_scanner);
//replace following function call with your own.
doYourMagicHere();
}
minmax_scan();
minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With