Adaptive several times to see someone ask questions about how to achieve the adaptive height of the IFRAME, able to automatically adapt to the length of the page to avoid the page and IFRAME at the same time the phenomenon of the scroll bar, just I encountered similar problems in the work, so the Internet search, East copy copy West Look, out of such a function, Posted to the page can be used. Do not dare to enjoy, if you feel useful, welcome to use
The source code is as follows
<script type= "Text/javascript" >
* * IFRAME automatically adapt to the page **//
Enter a list of the names of the IFRAME that you want to automatically adjust height based on the height of the page
Separate the IDs of each iframe with commas. For example: ["myframe1", "myframe2"], you can have only one form, no commas.
Define the ID of the IFRAME
var iframeids=["Test"]
If the user's browser does not support IFrame to hide the iframe and yes to hide, no means no hidden
var iframehide= "Yes"
function Dyniframesize ()
{
var dyniframe=new Array ()
for (i=0; i<iframeids.length; i++)
{
if (document.getElementById)
{
Automatically adjust the iframe height
Dyniframe[dyniframe.length] = document.getElementById (Iframeids[i]);
if (Dyniframe[i] &&!window.opera)
{
dyniframe[i].style.display= "Block"
if (dyniframe[i].contentdocument && dyniframe[i].contentdocument.body.offsetheight)//If the user's browser is Netscape
Dyniframe[i].height = Dyniframe[i].contentdocument.body.offsetheight;
else if (dyniframe[i). Document && Dyniframe[i]. Document.body.scrollHeight)//If the user's browser is IE
Dyniframe[i].height = Dyniframe[i]. Document.body.scrollHeight;
}
}
To handle the display of browsers that do not support IFRAME based on the parameters set
if ((document.all | | document.getelementbyid) && iframehide== "No")
{
var tempobj=document.all? Document.all[iframeids[i]]: document.getElementById (Iframeids[i])
tempobj.style.display= "Block"
}
}
}
if (Window.addeventlistener)
Window.addeventlistener ("Load", Dyniframesize, False)
else if (window.attachevent)
Window.attachevent ("onload", dyniframesize)
Else
Window.onload=dyniframesize
</script>
When you use it, just stick it in the