Jump to Real's How-to Main page

Resize an IFRAME based on its content

<script>
function calcIframeHeight() {
  var the_height=
    document.getElementById('iframecontent').contentWindow.
      document.body.scrollHeight;
  document.getElementById('iframecontent').height=
      the_height;
}

function go(page) {
document.getElementById('iframecontent').src=page;
}

</script>

...

<span onClick="go('topics/java-language.html')">Language</span><br>

<iframe src="welcome.html" 
    name="iframecontent" id="iframecontent" width="100%" height="100%" 
    scrolling="NO" frameborder="0" 
    onLoad="calcIframeHeight();window.scroll(0,0);">
</iframe>

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2007
[ home ]