Iframe auto resize doesn't work in FireFox

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>

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);
        }
      }

thanks fbronx !!!
very coollllll !!!
your script work in FireFox !!!

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¡¡¡¡

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?

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.

I am sorry, Its working in chrome but its not working in IE. :frowning:

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