Question

Despite of the fact that I have seen many articles (including in stackoverflow) demonstrating up how to bypass javascript's same origin policy assigning document.domain property, its not working. I also read in W3C specs that document.domain property is read-only and not all browsers accept setting it and I think that is the cause I can't get that working!

I have a page (domain d1.y.com.br) and I need to invoke a button in an embedded iframe's page (domain d2.x.com.br). I'm setting the parent document.domain attribute to subdomain 'x.com.br' but I'm still receiving the 'access denied' error message in firebug console.

I have also read about JSONP but its not the case here. I really need to interact with iframe's DOM and not only get data from there (using proxy service).

Does really exist any way to bypass same origin policy to interact with the iframe's DOM ???

Was it helpful?

Solution

The proper way to send data between iframes (especially across domains) is using postMessage(). https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage

That effectively "bypasses" the problem by having the recipient of the message verify that the caller has the correct domain - based on whatever rules it wants.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top