Library to delegate size of an iframe to the parent window.
$ npm install --save resizable-iframe
This repository only includes the CommonJS module.
If you wish to build this library without CommonJS environment run this commands:
npm i
npm run build
cd ./dist/
Below is a example of usage.
// require it
var ResizableIframe = require('resizable-iframe');
// create a new instance on domready. it will be started automatically
var resizableIframe;
domready(function() {
resizableIframe = new ResizableIframe();
});
// it can be stopped at any type
onSomeEvent(function() {
resizableIframe.stop();
});
// and later restarted
onSomeEvent(function() {
resizableIframe.start();
});
window.addEventListener('message', function(event) {
if (typeof event.data === 'string' && event.data.charAt(0) === '{') {
var msg = JSON.parse(event.data);
if (msg.iframeHeight) {
myIframe.style.height = msg.iframeHeight + 'px';
}
}
}, false);
Creates new instance of ResizableIframe
.
type: int
default: 1000
Defines the interval duration of the size check.
type: String
default: 'iframeName'
Name of the key with iframe's name value passed to the parent window.
type: String
default: 'iframeHeight'
Name of the key with iframe's height value passed to the parent window.
Starts the messaging to the parent window. Automatically called on new instance initialization.
Stops the messaging to the parent window.