Javascript / Frames / Dynamic Iframe resizing
I have seen this asked in more forums so i thought I would post it here in case anybody wants it.
this allows the iframe to go as big as the content inside it will want. so it really makes the heightof the iframe the same size as the content it loads in it.
browsers: IE6+, Mozilla, Netscape 6+
this allows the iframe to go as big as the content inside it will want. so it really makes the heightof the iframe the same size as the content it loads in it.
browsers: IE6+, Mozilla, Netscape 6+
General Details
Snippet uploaded by: snippet
Email : webmaster@snippetlibrary.com
Snippet By: Unknown
<!---Head--->
// add this to the page that loads "into" the iframe.
<script type="text/javascript">
function autofitIframe(id){
if (!window.opera && !document.mimeType && document.all && document.getElementById){
parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
}
else if(document.getElementById) {
parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
}
}
</script>
<!---Body--->
/// load this in the iframe page, the src of the iframe tag.
<body onload="autofitIframe('ifrm')" >
// in the parent file "calling" the iframe you need to make it have an id.
// add this to the parent html file.
<iframe name="ifrm" id="ifrm" src="test.htm" width="400" height="600" scrolling="no" frameborder="0">Sorry, your browser doesn't support iframes.</iframe>
No Reviews to show
