Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Iframe Resize to Content</title>
</head>
<body>
<script type='text/javascript'>
function sizeToMyContent( ifRef, setW, setH, fMargin )
{
var ifDoc, margin = typeof fMargin === 'number' ? fMargin : 16;
try
{
ifDoc = ifRef.contentWindow.document.getElementsByTagName("body")[0];
}
catch( e ){ ifDoc = null; }
if( ifDoc )
{
if( setH )
ifRef.height = ifDoc.scrollHeight + margin;
if( setW )
ifRef.width = ifDoc.scrollWidth + margin;
}
}
</script>
<iframe src="localPage.html" onload='sizeToMyContent(this, true, true)'></iframe>
</body>
</html>
Bookmarks