DEV Community

Discussion on: Cross-Domain Iframe-parent communication

Collapse
 
asimen1 profile image
Asaf

iframes shouldn't be hard :) I'm not sure why you ran across an issue doing postMessage cross-domains, but it's definitely not true that "cross-domain iframes don’t post message to the parent properly". In fact - quite the opposite, postMessage was designed to facilitate cross-domain messaging!

In any case I wrote a library that will make your life easier next time - it’s called iFramily (github.com/EkoLabs/iframily). Basically it has a simpler API than postMessage, which includes Promise-based responses, message queuing, and managing the connection until both frames are ready to talk. It also takes a responsible approach to security...

Would love to hear your thoughts!