Access Cross-Domain IFrame DOM Properties from Parent JavaScript

There are already several similar questions, but they usually cover the relationship between parents and parents.

I, on the other hand, would like to be able to get some IFrame DOM properties. I do not want to manipulate anything. I only want to be able to read properties or DOM nodes. Things like attributes or content.

AFAIK this is not possible unless I use something like window.postMessage . As smart as this solution, it is based on event listeners. This requires the listener to be defined inside the IFrame, and that means changing the IFrame code. I want to avoid this.

If you want to make an Ajax cross-domain call, you can (if you have access) set the headers of the target server so that:

 Access-Control-Allow-Headers:X-Requested-With Access-Control-Allow-Methods:POST,GET,DELETE,PUT,OPTIONS Access-Control-Allow-Origin:* 

This is interesting enough for communicating with an IFrame. So my question is:

(How) can I access the cross-domain IFrame DOM properties?

+7
source share
2 answers

I can’t even say how many times I have encountered such problems.

Read this community wiki about circumventing policies of the same origin to find a solution that works for you. This is one of the best resources of the same origin that I found on the Internet.

Alex Sexton yayQuery also compiled screencast on some other methods.

+2
source

I would give a chance http://easyxdm.net/wp/ used it many times, quite easy to use and works in older browsers.

+1
source

All Articles