Auto Resize IFrame

by Francis 2012-10-05 09:39:06

Auto Resize IFrame when web-page is loaded
Step : 1 - In Body Tag

<body onload="resizeFrame(document.getElementById('childframe'))">


Step : 2 - In JavaScript

// Firefox worked fine. Internet Explorer shows scrollbar because of frameborder
<script type="text/javascript">
function resizeFrame(f)
{
f.style.height = (f.contentWindow.document.body.scrollHeight + parseFloat(20)) + "px";
f.style.width = (f.contentWindow.document.body.scrollWidth + parseFloat(20)) + "px";
}
</script>


Step : 3 - In IFrame Tag

<iframe src="source-path" frameborder="0" id="childframe"> </iframe>
1078
like
3
dislike
6
mail
flag

You must LOGIN to add comments