473,403 Members | 2,359 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,403 software developers and data experts.

resizing iframe does not work in Firefox...

sam
Hi all,

Hope some expert can help me resolve this.

I am using the following code to resize an iframe according to the
content in it so that the iframe does not use its scroll bar and uses
the parent window scroll bar. This code works perfectly fine in IE but
not in Firefox.. The iframe does not resize according to the content.

function resizeIframe(id)
{
frame = document.getElementById(id);
innerDoc = (frame.contentDocument) ? frame.contentDocument :
frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;

if ( IE)
{ objToResize.height = innerDoc.body.scrollHeight + 3; }
else if (firefox)
{
objToResize.height = innerDoc.body.scrollHeight + 3;
alert(innerDoc.body.scrollHeight);
}
}

I noticed that (innerDoc.body.scrollHeight) works only when the iframe
just keeps on expanding for various calls.. But say after 1 or 2 calls
if the content is very little the iframe does not shrink back.

Any help really appreciated.

Thanks,
Sam

Apr 12 '06 #1
1 10581
sam wrote:
Hi all,

Hope some expert can help me resolve this.

I am using the following code to resize an iframe according to the
content in it so that the iframe does not use its scroll bar and uses
the parent window scroll bar. This code works perfectly fine in IE but
not in Firefox.. The iframe does not resize according to the content.

function resizeIframe(id)
{
frame = document.getElementById(id);
innerDoc = (frame.contentDocument) ? frame.contentDocument :
frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;

if ( IE)
{ objToResize.height = innerDoc.body.scrollHeight + 3; }
else if (firefox)
{
objToResize.height = innerDoc.body.scrollHeight + 3;
alert(innerDoc.body.scrollHeight);
}
}

I noticed that (innerDoc.body.scrollHeight) works only when the iframe
just keeps on expanding for various calls.. But say after 1 or 2 calls
if the content is very little the iframe does not shrink back.


Hi, sorry I don't have time to fiddle with this, but here's a page
snippet that might give you some ideas. But this is something I'm sure
I've read about in this group many times over.

Csaba Gabor from Vienna

<iframe id=fred style="border:1px solid red;height:4in;width:2in"
src="data:text/html,<body style='border:1px solid green'>
tiny<br>little<br>iframe</body>"
onload="iframeLoaded()">
</iframe>

<script type='text/javascript'>
function elem(id) { return document.getElementById(id); }
function iframeLoaded() {
var idoc = elem('fred').contentDocument;
idoc.body.innerHTML = "awideriframethatshouldbeallononeline";
var more = "<br>qwer<br>poiu";
for (var i=10;i--;) idoc.body.innerHTML += more;
alert(idoc.defaultView.location.href);
// see http://www.mozilla.org/docs/dom/domr...dow_ref76.html
idoc.defaultView.sizeToContent();
}
</script>

Apr 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: gsb | last post by:
Don't know if this is the right place to post this JavaScript issue. If not, could someone point me in the right direction please. I am trying to make a "cross browser compliant" floating...
4
by: khothikhe | last post by:
can some one help me here coz this is really killing me! the problem is, i have this javascript code in my aspx page that i want it to work on almost all browsers, especially opera and safari : ...
1
by: khothikhe | last post by:
Can someone help me here because this is really killing me! the problem is, i have this javascript code in my aspx page that i want it to work on almost all browsers, especially opera and safari...
5
by: Paul Fi | last post by:
Can someone help me here because this is really killing me! the problem is, i have this javascript code in my aspx page that i want it to work on almost all browsers, especially opera and safari...
14
by: Aaron Gray | last post by:
Hi, I want to access the properties of an IFrame but seem unable to get access to the IFrames document body. <html> <body> <iframe src="test.html" id="IFrame"></iframe> </body>
3
by: PCgeek | last post by:
sorry moved this over to javascript forum, didn't mean to post 2x! Hi guys, I'm trying to put the finishing touches on my website and could really use some help on this particular issue. My page...
3
by: visu | last post by:
Hi , I need a solution for my problem with IFRAME in firefox. The problem is that i ve to make the IFRAME to increase in its height to displays its whole content dynamically .i ve set...
13
by: bgraphics2031 | last post by:
I'm trying to get this iframe to dynamically resize by dragging a vertical bar, but it's not working in Mozilla (It originally worked in IE but I've been trying to port it over). Any help will be...
4
by: avdbrink | last post by:
I'm building an application wich should be used by other websites inside an iFrame. My app stores some sessionvariables, but sometimes in IE (6 and 7) IIS seems to restart the session on each...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.