|
John, there seems to be no obvious way to achieve this, but I managed to get the following to work:
This is the iframe element in the body section of the mother page:
<iframe name="iframetest" id="iframetest" src="test1.html" onload="size_iframe()"></iframe>
This is the javascript function that will be called when the page is loaded inside the iframe:
function size_iframe()
{
x = document.getElementById("iframetest");
y = frames.iframetest.document.getElementById("iframecontent");
if (document.all) // IE problem; wont show clientHeight if style height hasn't been set
y.style.height = "1px";
margin = 30;
x.style.height = parseInt(y.clientHeight + margin) + "px";
}
The script will set the HEIGHT of the iframe to that of the content of the child page. It has to add a margin (depends both of the child page and of the browser, but 30 should do).
The only thing you NEED to do is to fit the actual content of the child page (test1.html) inside a DIV tag like this:
<body>
<div id="iframecontent">
test file to load inside the iframe<br>
can be of variable height
</div>
</body>
Otherwise, I couldn't get it to work. The BODY element doesn't seem to want to report its clientHeight.
This example has been tested in IE6 and FF 1.5
Hope it is useful, - if you want me to change it according to your needs, please say so.
Jakob
|
|
Expert:
|
jgivoni
|
|
Date:
|
Sep 16, 2006
|
|
Time:
|
19:41
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
|
|
|
|
This question has been answered, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.
|
|