Showing posts with label resize. Show all posts
Showing posts with label resize. Show all posts

Thursday, August 29, 2013

Setting the IFrame height dynamically

Awesome HTML5 feature that helps to set the IFrame height dynamically.

Use the following script

<script type="text/javascript" >
$(document).ready(function(){
    window.setInterval(resizeParentIframe, 2000);
 });

var pastHeight = 0;

function resizeParentIframe() {
var currentHeight = document.body.scrollHeight;
if (currentHeight != pastHeight){
pastHeight = currentHeight;
parent.postMessage(document.body.scrollHeight, '*');
}
}
</script>