Page | adaptive
Main.htm:
<meta http-equiv= ' content-type ' content= ' text/html; charset=gb2312 '/>
<meta name= ' author ' content= ' F.r.huang (meizz plum blossom Snow)//www.meizz.com '/>
<title>iframe Adaptive Load Page height </title>
<body>
<div><iframe src= "child.htm" ></iframe></div>
</body>
Child.htm:
<meta http-equiv= ' content-type ' content= ' text/html; charset=gb2312 '/>
<meta name= ' author ' content= ' F.r.huang (meizz plum blossom Snow)//www.meizz.com '/>
<title>iframe Adaptive to its loaded Web page (multi-browser compatible) </title>
<script type= "Text/javascript" >
<!--
function Iframeautofit ()
{
Try
{
if (window!=parent)
{
var a = Parent.document.getElementsByTagName ("IFRAME");
for (var i=0; i<a.length; i++)//author:meizz
{
if (A[i].contentwindow==window)
{
var h1=0, h2=0;
A[i].parentnode.style.height = a[i].offsetheight + "px";
A[i].style.height = "10px";
if (document.documentelement&&document.documentelement.scrollheight)
{
H1=document.documentelement.scrollheight;
}
if (document.body) h2=document.body.scrollheight;
var H=math.max (H1, H2);
if (document.all) {h = 4;}
if (window.opera) {h = 1;}
A[i].style.height = A[i].parentnode.style.height = h + "px";
}
}
}
}
catch (ex) {}
}
if (window.attachevent)
{
Window.attachevent ("onload", Iframeautofit);
Window.attachevent ("OnResize", Iframeautofit);
}
else if (Window.addeventlistener)
{
Window.addeventlistener (' Load ', Iframeautofit, false);
Window.addeventlistener (' Resize ', Iframeautofit, false);
}
-->
</script>
<body>
<table border= "1" width= "style=" height:400px; Background-color:yellow ">
<tr>
<td>iframe Adaptive to its loaded Web page (multi-browser compatible, support XHTML) </td>
</tr>
</table>
</body>
Many people react to IE7 using it to panic because the Window.onresize event is triggered when the altitude is adaptive, and this event calls the adjustment <iframe> height function, resulting in a dead loop call.