IT Fixes..

Solutions to common IT related issues

Dynamic IFRAME Resizing

Posted by Daman Dang on June 9, 2008

IFRAMEs are generally not considered a good idea to use but sometimes it really helps. But resizing an IFRAME as per the content is a big issue and I found a piece of code after some search which can resolve this issue.

In the head of your document enter the following JavaScript code:

<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>

and in the body create the iframe tag:

This will create an IFRAME of width=700 and the height will depend on the content it stores.

Reference: Guymal Code

About these ads

2 Responses to “Dynamic IFRAME Resizing”

  1. john said

    this doesn’t work.

  2. Daman Dang said

    I have myself used it couple of times so I can bet it works. There must be some other issue. Make sure you are using the same IFRAME ID in both pieces of the code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: