<iframe> javascript access parent DOM across domains?

cross-domain, dom, iframe, javascript

Solution

Hate to say it but I'm like 99% sure that ain't happening directly because of security.

You can try it out here.

bhh

Problem

I control the content of an iframe which is embedded in a page from another domain. Is there any way for javascript in my iframe to make changes to the parent's DOM? For example, I would like to have my iframed script add a bunch of html elements to the parent DOM. This seems like a pretty tall order - thoughts? Edit: There exists a technique called "Fragment ID Messaging" which might be a way to communicate between cross-domain iframes. Edit: Also, Firefox 3.5, Opera, Chrome (etc) seem to be adopting the html5 "postMessage" api, which allows secure, cross-domain data transmission between frames, iframes and popups. It works like an event system. IE8 supports this feature, apparently, which is perhaps a little surprising. Summary: No, you can't directly access/edit the DOM of a page from another domain. But you can communicate with it, and it can co-operate to make the changes you want.

Original source