resizing iframe height according to its content in firefox

Discussion in 'Javascript' started by visu, Feb 28, 2007.

  1. visu

    visu Guest

    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 there anyway to increase the height of the
    IFRAME dynamically depends on its content in FIREFOX?

    The code worked for me in IE is

    var FramePageHeight =
    document.getElementById('iframeID').scrollHeight;
    document.getElementById('iframeID').style.height=FramePageHeight;

    can any one help for firefox?
    Thanx in advance.

    Regards
    Visu
     
    visu, Feb 28, 2007
    #1
    1. Advertising

  2. visu

    Ralf Beutler Guest

    Ralf Beutler, Feb 28, 2007
    #2
    1. Advertising

  3. On Feb 28, 12:41 am, "visu" <> wrote:
    > 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 there anyway to increase the height of the
    > IFRAME dynamically depends on its content in FIREFOX?
    >
    > The code worked for me in IE is
    >
    > var FramePageHeight =
    > document.getElementById('iframeID').scrollHeight;
    > document.getElementById('iframeID').style.height=FramePageHeight;
    >
    > can any one help for firefox?
    > Thanx in advance.
    >
    > Regards
    > Visu


    I assume you've checked the value of FramePageHeight and it's > 0. In
    Firefox you need to tack on "px" when you set style.height to a pixel
    value. For example:
    document.getElementById("iframeID").style.height = FramePageHeight +
    "px";

    - Larry
     
    Larry Marburger, Feb 28, 2007
    #3
  4. On or about 2/28/2007 12:41 AM, it came to pass that visu wrote:
    > 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 there anyway to increase the height of the
    > IFRAME dynamically depends on its content in FIREFOX?
    >
    > The code worked for me in IE is
    >
    > var FramePageHeight =
    > document.getElementById('iframeID').scrollHeight;
    > document.getElementById('iframeID').style.height=FramePageHeight;
    >
    > can any one help for firefox?
    > Thanx in advance.
    >
    > Regards
    > Visu
    >

    If you are not going cross-domain then look at
    http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm

    It seems the DOM varies in FF and IE7 for the IFRAME document data or
    I've just not found the magic words. I've not found any solution for
    cross-domain IFRAMEs because the browsers restrict getting the height of
    the foreign document, or anything else for that matter.

    FF
    var FramePageHeight =
    document.getElementById('iframeID').contentDocument.body.scrollHeight;


    IE7
    var FramePageHeight =
    document.getElementById('iframeID').Document.body.scrollHeight;

    or just do a simple if
    if (document.getElementById('iframeID').Document.body.scrollHeight)
    do something
    else
    if document.getElementById('iframeID').contentDocument.body.scrollHeight)
    do something
     
    totalstranger, Mar 1, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lo?c Mah?
    Replies:
    2
    Views:
    1,736
    Lo?c Mah?
    Nov 29, 2004
  2. Replies:
    1
    Views:
    206
  3. Pil (Trustworthy from Experience)

    Resizing a div by resizing its borders

    Pil (Trustworthy from Experience), Apr 18, 2009, in forum: Javascript
    Replies:
    9
    Views:
    360
    Proper
    Apr 21, 2009
  4. Proper
    Replies:
    0
    Views:
    207
    Proper
    Apr 18, 2009
  5. Zarkas

    resize iframe according to content

    Zarkas, Jun 13, 2010, in forum: Javascript
    Replies:
    12
    Views:
    322
    Evertjan.
    Jun 17, 2010
Loading...

Share This Page