Resize iframe to show first element works except in IE 7

Posted by Rob Fenwick on Stack Overflow See other posts from Stack Overflow or by Rob Fenwick
Published on 2011-01-13T18:48:26Z Indexed on 2011/01/13 18:54 UTC
Read the original article Hit count: 219

Filed under:
|

I have two iframes on my home page, the script below is in the head of the page that is being displayed in the iframe, there are several divisions on the page in a container div with an id of 'content', I want to size the iframe on the home page so that just the first div is initially seen and to scroll to see the rest.

It is working in all browsers that I have tried except IE 7, I don't care too much about earlier browsers. IE 7 is acting like the page being shown is blank and sizing the iframe to 0 height, can someone tell me why IE 7 is having a problem with it, and failing that how can I get IE 7 to ignore the script?

function resizeIframe() {

//get the firstChild of a container div with the id 'content'

var div01 = document.getElementById("content").firstChild;

//find the first element ignoring white spaces and returns

while(div01.nodeType!=1){ div01 = div01.nextSibling; }

// get the height of first element

var boxHeight = div01.clientHeight;

//set the height of iframe the id of the iframe is 'news'

parent.document.getElementById('news').height = boxHeight; }

I have the function called in the body tag.

If someone could help me I'd very much appreciate it.

The page that it is on is at wsuu.org The version with the script is not up but you can get an idea of what I'm trying to do.

Rob

© Stack Overflow or respective owner

Related posts about iframe

Related posts about resize