2010-11-30 18:30:56 | Author:

normally, when you create a new iframe and set its src to about:blank, you can access its contents, like this:

bla.innerHTML = '<iframe src="about:blank" id="foo" ></iframe>';

// and, once its loaded:

document.getElementById('foo').contentWindow.document.write('things...');

Internet Explorer, at first glance pretty randomly, explodes in your face with an “Access denied” message when you try to access the document.
I suspected lots of different things, and needed days to finally figure it out:

If the parent window’s document.domain property has been explicitly set at some point, an empty frame is treated as belonging to different domain.

And because we cannot cross domain boundaries, yadda yadda yadda, access to their content is denied.

Workaround: set the iframe’s source not to “about:blank”, but to “blank.html”, for example. It does not matter if that page exists or not: to Internet Explorer, the frame willl be from the same domain, and all is well. That’s actually the same thing doubleclick/ Google Ads does.

Category: DOM
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply