By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

iframe autosize problem in firefox. Ok in IE. Help!

P: n/a
Usual apologies if this is old territory.

I'm resizing a bunch of iframes on a page to the height of their
contained documents. Some of the contained documents contain IMG tags.
On IE this doesn't cause a problem and the resize works correctly. On
Firefox, if an image extends below the last line of text in the
document, that bit gets chopped off. In other words, the returned
document height doesn't allow for the image.

My code for resizing an Iframe is:

function adjustIFrameSize (iframe)
{
if ( iframe.contentDocument ) // firefox
{
iframe.height = iframe.contentDocument.height;
}
else // IE
{
iframe.style.height =
iframe.contentWindow.document.body.scrollHeight;
}

}

Can someone tell me how I can modify the firefox line to make it do the
job correctly.

Many thanks.

Dave

Oct 24 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I've found the answer so I thought I'd post it here for reference.

First, wait for all the iframes to load. In other words, call an onload
function in the body tag.

In that function, set each iframe height as follows:

iframe.height = iframe.contentDocument.documentElement.scrollHeigh t;

This works great on firefox.

Dave wrote:
Usual apologies if this is old territory.

I'm resizing a bunch of iframes on a page to the height of their
contained documents. Some of the contained documents contain IMG tags.
On IE this doesn't cause a problem and the resize works correctly. On
Firefox, if an image extends below the last line of text in the
document, that bit gets chopped off. In other words, the returned
document height doesn't allow for the image.

My code for resizing an Iframe is:

function adjustIFrameSize (iframe)
{
if ( iframe.contentDocument ) // firefox
{
iframe.height = iframe.contentDocument.height;
}
else // IE
{
iframe.style.height =
iframe.contentWindow.document.body.scrollHeight;
}

}

Can someone tell me how I can modify the firefox line to make it do the
job correctly.

Many thanks.

Dave
Oct 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.