Creative Jar Blog RSS Feed

Dynamically adjusting height of IFRAME from child page

October 20, 2008 11:20 by nat

I had to do this recently and thought it would be tougher than it ended up being. Here's the code I used:

function adjustMyFrameHeight()
{
var frame = getElement("myFrame");
frame.height = document.body.offsetHeight + 60 + "px"; // add 60 pixels to be safe...
}

function getElement(aID)
{
return (document.getElementById) ?
     parent.document.getElementById(aID) : parent.document.all[aID];
}

Then, just simply call the "adjustMyFrameHeight()" method from the child page's BODY onload event:

<body onload="adjustMyFrameHeight();">

Et voila, c'est bon!!


Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments

October 28. 2008 23:11

Great, thanks a lot!

Mike

Add comment


 

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

January 6. 2009 12:18

Calendar

January 2009
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567