https://github.com/cristianoliveira/ifrone
A tiny wrapper around cross-window communication.
https://github.com/cristianoliveira/ifrone
iframe iframe-communication iframe-pubsub lightweight pubsub wrapper
Last synced: 11 months ago
JSON representation
A tiny wrapper around cross-window communication.
- Host: GitHub
- URL: https://github.com/cristianoliveira/ifrone
- Owner: cristianoliveira
- License: mit
- Created: 2020-08-29T17:13:08.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-08T15:59:25.000Z (over 5 years ago)
- Last Synced: 2025-03-11T02:26:34.994Z (over 1 year ago)
- Topics: iframe, iframe-communication, iframe-pubsub, lightweight, pubsub, wrapper
- Language: JavaScript
- Homepage:
- Size: 150 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ifrone.
[](https://www.npmjs.com/package/ifrone)
A tiny wrapper around cross-window communication.
This feature is normally used for communication between a page host and an iframe.
## Example
```javascript
const iframe = document.getElementById('myiframe');
var iph = ifrone.connect({
from: window,
to: iframe.contentWindow,
host: '*'
})
iph.on('myIframeEvent', (event) => {
console.log('myIframeEvent', event);
})
setInterval(() => {
iph.send('myHostEvent', 'fooo')
}, 1000)
iph.ack('myHostEvent', (event) => {
console.log('on ack myHostEvent', event);
})
```
## Running tests
```
yarn test
```