https://github.com/fetch/frame-bridge
Minimal JS frame bridge, using window.postMessage
https://github.com/fetch/frame-bridge
Last synced: 10 months ago
JSON representation
Minimal JS frame bridge, using window.postMessage
- Host: GitHub
- URL: https://github.com/fetch/frame-bridge
- Owner: fetch
- Created: 2015-02-25T15:42:57.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-25T11:11:35.000Z (about 10 years ago)
- Last Synced: 2025-02-14T07:06:27.959Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FrameBridge JS
Minimal frame bridge, using `window.postMessage`.
To communicate between two frames you simply instantiate an instance of `FrameBridge` in both parent and child.
Take for example the following parent page:
```html
var frame = document.getElementById('child-page');
var bridge = new FrameBridge({target: frame});
bridge.on('setFrameHeight', function(height){
frame.height = height;
});
```
With a child page like this:
```html
....
var bridge = new FrameBridge();
window.onload = function(){
bridge.trigger('setFrameHeight', document.body.clientHeight);
};
```
This would resize the frame in the parent window to match the actual size of the content.