Results 1 to 2 of 2

Thread: matching div height to dynamic Iframe height

  1. #1
    Join Date
    Oct 2007
    Location
    Wisconsin USA
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default matching div height to dynamic Iframe height

    Hi all. I have an Iframe that is contained within a div. The Iframe has a script attached that dynamically adjusts its height to the height of the Iframes content. The div it is contained in has a background image that is repeated on the y axis. I'm having problems with the Iframe extending past the div and therefore not continuing the background.


    here is the section of script that adjusts the height of the frame. the variable divStretch is the div im trying to adjust
    I thought it would be as simple as adding a divStretch.height = currentfr.height; statment however that is not working.

    Code:
    function resizeIframe(frameid){
    var currentfr=document.getElementById(frameid)
    var divStretch=document.getElementById('content');
    if (currentfr && !window.opera){
    currentfr.style.display="block"
    if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
    currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
    divStretch.style.height = currentfr.height + 'px';
    else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
    currentfr.height = currentfr.Document.body.scrollHeight;
    if (currentfr.addEventListener)
    currentfr.addEventListener("load", readjustIframe, false)
    else if (currentfr.attachEvent){
    currentfr.detachEvent("onload", readjustIframe) // Bug fix line
    currentfr.attachEvent("onload", readjustIframe)
    }
    }
    }
    any help is much appreciated.

  2. #2
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    document should be lowercased.
    Trinithis

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •