-1

I'm getting the Cross Domain error in Chrome. Using javascript on a page inside an iframe to write data inside itself. I'm not breaking any cross-domain rules, per se. I believe I'm seeing the error because I'm using document.write() or document.getElementById() in the iframe's page and it's causing the browser to think i'm referencing the parent document.


parent.html sits on domainA.com

<iframe src="iframe.html"></iframe>


iframe.html sits on domainB.com

<html>
    <head>
        <title>iFrame</title>
    </head>
    <body>
        <script type="text/javascript">
            document.write('hello world');
        </script>
    </body>
</html>

I should also note that I've tried self.document.write() to no avail. Is there something I'm missing here?

ndmweb
  • 3,370
  • 6
  • 33
  • 37
  • so this only happens in chrome? did you try window.document.write in the iframe? – John Culviner Jul 05 '12 at 22:19
  • Tried just about every DOM path I could think of. `window.document.write` `self.document.write`.. nada – ndmweb Jul 06 '12 at 00:39
  • I should note that nothing seems to break, just spits the error out. The contents are in fact written to the iframe document. – ndmweb Jul 06 '12 at 00:41

1 Answers1

0

Since nothing is broken and it only happens in chrome I'm thinking it is likely a know debugger issue that is likely causing this. Take a look at this post Debugging iframes with Chrome developer tools

Community
  • 1
  • 1
John Culviner
  • 22,235
  • 6
  • 55
  • 51