473,545 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.getEle mentById(id);
innerDoc = (frame.contentD ocument) ? frame.contentDo cument :
frame.contentWi ndow.document;
objToResize = (frame.style) ? frame.style : frame;

if ( IE)
{ objToResize.hei ght = innerDoc.body.s crollHeight + 3; }
else if (firefox)
{
objToResize.hei ght = innerDoc.body.s crollHeight + 3;
alert(innerDoc. body.scrollHeig ht);
}
}

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 10604
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.getEle mentById(id);
innerDoc = (frame.contentD ocument) ? frame.contentDo cument :
frame.contentWi ndow.document;
objToResize = (frame.style) ? frame.style : frame;

if ( IE)
{ objToResize.hei ght = innerDoc.body.s crollHeight + 3; }
else if (firefox)
{
objToResize.hei ght = innerDoc.body.s crollHeight + 3;
alert(innerDoc. body.scrollHeig ht);
}
}

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:1 px solid red;height:4in; width:2in"
src="data:text/html,<body style='border:1 px solid green'>
tiny<br>little< br>iframe</body>"
onload="iframeL oaded()">
</iframe>

<script type='text/javascript'>
function elem(id) { return document.getEle mentById(id); }
function iframeLoaded() {
var idoc = elem('fred').co ntentDocument;
idoc.body.inner HTML = "awideriframeth atshouldbeallon oneline";
var more = "<br>qwer<br>po iu";
for (var i=10;i--;) idoc.body.inner HTML += more;
alert(idoc.defa ultView.locatio n.href);
// see http://www.mozilla.org/docs/dom/domr...dow_ref76.html
idoc.defaultVie w.sizeToContent ();
}
</script>

Apr 13 '06 #2

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

Similar topics

6
5721
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 iFrame. Not real fancy, just load, resize and move. But, I do not have the browsers, OSs and different machines (like Mac) to test the code on. So I...
4
1942
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 : function resize(){ displayFrm = document.getElementById("ifrmDisplay"); innerDoc = (displayFrame.contentDocument) ?displayFrm.contentDocument :...
1
2375
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 : function resize(){ displayFrm = document.getElementById("ifrmDisplay"); innerDoc = (displayFrame.contentDocument) ?displayFrm.contentDocument...
5
1735
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 : function resize(){ displayFrm = document.getElementById("ifrmDisplay"); innerDoc = (displayFrame.contentDocument) ?displayFrm.contentDocument...
14
18266
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
4473
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 includes background music with a javascript music player on the main page below an iframe that is used for all content and navigation of the site and...
3
18540
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 scrolling=0 ,i dont want the scroll bars to appear in the IFRAME. I ve achieved this somehow thru javascript in IE.. but it is not working in Firefox.. is...
13
4383
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 appreciated. Here's the resize.js var sResizableElement = "TH"; //Elements to be resized var iResizeThreshold = 8; var iEdgeThreshold = 8; var...
4
4900
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 pageload. It does this when I post the page, or request the page, no matter what. My sessionId is changing, wich prevents me from storing for example a...
0
7675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7928
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5997
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.