Make your iframe(s) resize automatically. Cross-domain. Dependency-free.
Same-origin policy prevents reading an iframe's document height from the host page. ElasticFrame makes your iframe talk to the host page about its actual document height whenever it changes. The host will then update the iframe height accordingly to avoid scrollbars.
- Cross-domain
- Light-weight
- CommonJS, AMD & browser global
- This involves including a light-weight script into both the host and the iframe page.
Add this to the iframe content page:
<script src="elasticframe.js"></script>
<script>
ElasticFrame.initIframe();
</script>
Then add this to the host page containing the iframe:
<script src="elasticframe.js"></script>
<script>
ElasticFrame.initParent(HTMLIFrameElement);
</script>
For situations where manual resizing is necessary:
var eframe = ElasticFrame.initParent(HTMLIFrameElement);
eframe.resize();
var eframe = ElasticFrame.initIframe();
eframe.resize();
IE8+, Firefox, Chrome, Safari, Opera
https://github.com/TYPE10/elasticframe/contributors
Copyright © 2016 TYPE10 Media
Licensed under the MIT license.