Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pbojinov/iframe-communication
Basic two way iframe communication
https://github.com/pbojinov/iframe-communication
communication cross-domain html5 iframe javascript
Last synced: 16 days ago
JSON representation
Basic two way iframe communication
- Host: GitHub
- URL: https://github.com/pbojinov/iframe-communication
- Owner: pbojinov
- Created: 2014-02-12T21:58:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-03-12T08:45:09.000Z (over 10 years ago)
- Last Synced: 2024-10-12T03:09:14.010Z (about 1 month ago)
- Topics: communication, cross-domain, html5, iframe, javascript
- Homepage: http://pbojinov.github.io/iframe-communication/
- Size: 168 KB
- Stars: 92
- Watchers: 3
- Forks: 41
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Two way iframe communication
Seamless communication between an iframe and a parent page.
## Demo
[http://pbojinov.github.io/iframe-communication](http://pbojinov.github.io/iframe-communication/)
The main difference between the code in the two pages (parent and iframe) is the method of sending messages. Recieving 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