PDA

View Full Version : matching div height to dynamic Iframe height



Kevisazombie
10-07-2007, 06:52 PM
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.


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.

Trinithis
10-07-2007, 10:22 PM
document should be lowercased.