473,386 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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
1 10358
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Razzbar | last post by:
I've written several utility pages that use a dynamically created iframe. The iframe typically has a form that is populated by the main page. Then the form is submitted to be processed, and the...
2
by: delraydog | last post by:
I know that innerText is not supported in FireFox and I've found the following code fragment which was originally designed in an HTMLElement prototype for an innerText getter. I do not however want...
1
by: Steven | last post by:
I am having problems with IFrames and Firefox. To make things simple I have index.html and frame.html: ------------ index.html ----------------- <html> <head> <title></title> <script...
1
by: chaitatp | last post by:
Hi friends, I've got a problem about inserting Flash in iframe in Firefox. The codes are: ---- test.html ---- <html> <head> <script type="text/javascript"> function doBodyOnLoad()
3
by: juergen.riemer | last post by:
Hi all, I have a problem in attaching an external stylesheet to a newly created iframe in Firefox (1.5.0.2). If I use the code below (with a relative address to the file) the stylesheet would...
8
by: hyejin | last post by:
I have a problem with dynamic iframe and document.close() on Firefox. Below two files create a dynamic iframe by JavaScript. These two samples do not have any problems on IE. But, on Firefox, the...
3
by: reflex | last post by:
Hi, i am using onmouse tooltip on my website. Under them i use iframe to hide form elements if is tooltip above them. Everything works fine only at firefox there is +-1sec "refresh" when tooltip...
1
by: thulaseeram | last post by:
I am using iframe to store uploaded images, it is uploading fine in IE but it is not happening in firefox means first time it is uploading image if i try to upload second image it is not calling even...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.