Jump to content

[SOLVED] auto iFrame height and website height


tushar707

Recommended Posts

Hello,

I have an iframe that changes its content according to the menu.  How do I have the iFrame adjust its height according to content?  Also how do I have the content area where the iframe is located to adjust its height according to the iframe?

-tushar

Link to comment
Share on other sites

  • 2 years later...

Below is some javascript code that will automatically expand the iframes that we currently use to embed forms.

 

(1) Paste The blow to the head

 

<script language="JavaScript">
<!--
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindow.
document.body.scrollHeight;

//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
//-->
</script>

(2)Paste the code below to the body and replace "your page here" with your url

 

 

<iframe width="100%" id="the_iframe"
onLoad="calcHeight();"
src="your page here"
scrolling="NO"
frameborder="0"
height="1">
An iframe capable browser is
required to view this web site.
</iframe>

 

I hope this helps others wonting this solution

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.