Skip to content

SokolskyNikita/cross-domain-iframe-communication

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Two way cross domain iframe communication

Seamless communication between a parent page on one domain and an iframe on a different domain. It relies on window.postMessage() and works in IE11 and all modern browsers.

Forked from @pbojinov's work originally, as it only had a single domain example.

Demo

https://sokolskynikita.github.io/cross-domain-iframe-communication/

The main difference between the code in the two pages (parent and iframe) is the method of sending messages. Receiving messages is done using the same code.

parent

Send message to iframe using iframeEl.contentWindow.postMessage

Recieve message using window.addEventListener('message')

iframe

Send message to parent window using window.parent.postMessage

Recieve message using window.addEventListener('message')

License

MIT

Releases

No releases published

Packages

No packages published

Languages

  • HTML 100.0%