fbronx
June 16, 2005, 8:11pm
1
The following script works in IE, but doesn’t in FireFox. Anybody an idea why?
function changeHeight(iframe)
{
try
{
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
var objToResize = (iframe.style) ? iframe.style : iframe;
objToResize.height = innerDoc.body.scrollHeight + 10;
}
catch(err)
{
alert(err.message);
}
}
The IFRAME is defined as follows:
<iframe id="editSectionFrame" frameborder="0"
style="display:block;width:100%"
onLoad="changeHeight(this);"
src="section.php">
</iframe>
fbronx
June 17, 2005, 2:36pm
2
Solved with the following:
function changeHeight(iframe)
{
try
{
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
if (innerDoc.body.offsetHeight) //ns6 syntax
{
iframe.height = innerDoc.body.offsetHeight + 32; //Extra height FireFox
}
else if (iframe.Document && iframe.Document.body.scrollHeight) //ie5+ syntax
{
iframe.height = iframe.Document.body.scrollHeight;
}
}
catch(err)
{
alert(err.message);
}
}
reck
June 30, 2005, 7:00pm
3
thanks fbronx !!!
very coollllll !!!
your script work in FireFox !!!
monclee
September 18, 2006, 4:13pm
4
I just cant put this to work on Firefox, what am i doing wrong? :injured:
By the way i just copied and tried to useit on my page. see my test
heres the site where i cant put the script for the auto height iframe
http://www.promoclubmexico.com/mexico/queretaro/tests.php
For Now i have been on this since last week
Heeeeeeelp¡¡¡¡
fbronx:
The following script works in IE, but doesn’t in FireFox. Anybody an idea why?
function changeHeight(iframe)
{
try
{
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
var objToResize = (iframe.style) ? iframe.style : iframe;
objToResize.height = innerDoc.body.scrollHeight + 10;
}
catch(err)
{
alert(err.message);
}
}
The IFRAME is defined as follows:
<iframe id="editSectionFrame" frameborder="0"
style="display:block;width:100%"
onLoad="changeHeight(this);"
src="section.php">
</iframe>
The problem is firefox does not recognize the “onLoad” event. I’ve noticed this on every attempt to find a solution. I’m designing a guild website for World of Warcraft, yet there is nobody that I can find that uses anything BUT onLoad in the iframe tag. That just won’t work in firefox. Is there a way to call this code without onLoad?
deepM
November 6, 2009, 6:13am
6
fbronx:
Solved with the following:
function changeHeight(iframe)
{
try
{
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
if (innerDoc.body.offsetHeight) //ns6 syntax
{
iframe.height = innerDoc.body.offsetHeight + 32; //Extra height FireFox
}
else if (iframe.Document && iframe.Document.body.scrollHeight) //ie5+ syntax
{
iframe.height = iframe.Document.body.scrollHeight;
}
}
catch(err)
{
alert(err.message);
}
}
Yes its work with Mozilla, but its not working with IE and Chrome. Can anyone tell me how can i make it work this in both the browser as well?
Thanks in advance.
deepM
November 6, 2009, 6:45am
7
I am sorry, Its working in chrome but its not working in IE.
fbronx:
Solved with the following:
function changeHeight(iframe)
{
try
{
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
if (innerDoc.body.offsetHeight) //ns6 syntax
{
iframe.height = innerDoc.body.offsetHeight + 32; //Extra height FireFox
}
else if (iframe.Document && iframe.Document.body.scrollHeight) //ie5+ syntax
{
iframe.height = iframe.Document.body.scrollHeight;
}
}
catch(err)
{
alert(err.message);
}
}
This code is very good. It’s works in Firefox 3., ie 8 and chrome.
but I only script :
function changeHeight(id)
{
var page_height = document.getElementById(id).contentWindow.document.body.scrollHeight;
document.getElementById(id).height = page_height+50;
}
i’m tested. It’s works in Firefox 3., ie 8 and chrome. Every an explain?
please reply to email: minhquang12g@gmail.com
Thank’s All