An open API service indexing awesome lists of open source software.

https://github.com/funtechinc/handshake

🤝 Shake hands with iframe
https://github.com/funtechinc/handshake

Last synced: 4 months ago
JSON representation

🤝 Shake hands with iframe

Awesome Lists containing this project

README

          

Promise-based postMessage iframe communication library.
0 dependencies, Lightweight.

```bash
$ npm i @funtech-inc/handshake --D
```

```html
// CDN

```

## Example

**parent**

```javascript
new Handshake.Parent({
container: "container",
url: "http://example.com/child",
}).ready(({ on, emit, container, iframe }) => {
console.log(container); // HTMLElement
console.log(iframe); // HTMLIFrameElement
emit("parentToChild", "hello child");
on("childToParent", (data) => {
console.log(data);
}); // Log... "hello parent"
});
```

**child**

```javascript
new Handshake.Child({ url: "http://example.com/" }).ready(({ on, emit }) => {
emit("childToParent", "hello parent");
on("parentToChild", (data) => {
console.log(data);
}); // Log... "hello child"
});
```

### License

MIT