Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iFrame height

Status
Not open for further replies.

IonCurici

Programmer
Oct 29, 2002
24
MD
how can i set the height of the iframe dynamic, so that it fit its contents - i mean so that there would appear no scrollbar, but at the same time the document inside would not be cropped?
 
This question is asked so much that I'd write an FAQ, but the answer is so short to make it not worth it:
You can't.

Sorry,
Rick -----------------------------------------------------------
 
Actually, it is indeed possible to have your IFrame sized based on content, and here's the code to do it:
Code:
<script language="JavaScript" type="text/javascript">
<!--

function frm_onload(frmname)
{
frmname.frameElement.height = frmname.document.body.scrollHeight+20;
}

//-->
</script>

And put the following in your IFrame tag:
Code:
language=javascript onload="return frm_onload(frameid)"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top