Access Parent Window From Iframe (cross-domain)
Answer :
If I were you I would check out window.postMessage. It may do what you want:
For reference see the following:
- MDN - Window.postMessage
- https://stackoverflow.com/a/3076648/296889 - see the Window.postMessage section
If I understand correctly, all modern browsers do now allow to do this. So I'm here to find the best solution.
This is your solution. What you're asking is not possible.
See related questions:
- How to access parent Iframe from JavaScript
- <iframe> javascript access parent DOM across domains?
- Cross-domain access in iframe from child to parent
EDIT
As mentioned in the comments below, @JeremysAwesome's answer offers a method that would allow cross-domain requests under certain circumstances. See the SO question below for more information.
Ways to circumvent the same-origin policy
but you can change the src
attribute of the iframe
(adding a #hashtag
for example) and listen to the onhashchange
event in the child window. Given that you're in position to change both pages.
Comments
Post a Comment