Click to See Complete Forum and Search --> : iFrame height


gsb
06-20-2003, 07:43 PM
I need to use an iFrame on part of my site.
Is there a way to make the iFrame 'dynamically size' (height) to avoid the scroll bars for long pages?

Thanks.

pyro
06-20-2003, 10:57 PM
Theoretically, this will work more cross-browser:

<script language="JavaScript" type="text/JavaScript">
function setHeight() {
docheight = document.body.scrollHeight;
document.getElementById("myiframe").style.height= docheight+"px";
}

</script>
</head>
<body onload="setHeight();">
<iframe id="myiframe"></iframe>

gsb
06-21-2003, 09:42 AM
Thanks again, but not exactly what I was trying to do.

I really want the iFrame to dynamically expand/contract to match the page being loaded into it. Like a DIV would do when you change its innerHTML.

Would overflow-y work?

Thanks again.

pyro
06-21-2003, 10:41 PM
alert (document.body.scrollHeight);

will return values in IE, Mozilla, NN, and Opera, at least. I believe that the onload statement in the iframe is what causes it not to work in non IE browsers.

dwd
03-05-2004, 01:02 PM
This works, except that it generates an Object Required error.
<iframe style="width:expression(main.document.body.scrollWidth);
height:expression(main.document.body.scrollHeight);"
name="main" id="main" width="500" src="home.htm"
scrolling=no frameborder=1></iframe><p>
<a href="Calendar.cfm" target="main">

If anyone can expalin the error we will be all set.

You can see it at
http://testmän.nu/

pyro
03-05-2004, 01:10 PM
Did you fail to realize that this thread was 8 1/2 months old? :confused:

dwd
03-05-2004, 01:25 PM
I was hoping someone could explain my error.
Anyway, did he ever get an answer?

pyro
03-05-2004, 01:46 PM
Originally posted by dwd
I was hoping someone could explain my error.Then start a new thread, please.