Javascript| Loading | adaptive
JavaScript application: IFRAME Adaptive to its loaded content height
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>
<iframe src= "child.htm" ></iframe>
</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 language=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 h = document.body.scrollHeight;
if (document.all) {h = 4;}
if (window.opera) {h = 1;}
A[i].style.height = h;
}
}
}
}
catch (ex)
{
Alert (script cannot operate across domains!) ");
}
}
if (document.attachevent) window.attachevent ("onload", Iframeautofit);
else Window.addeventlistener (' Load ', Iframeautofit, false);
</script>
<body>
<div style= "WIDTH:200; height:400; Background-color:yellow ">
IFRAME Adaptive to its loaded Web page (multi-browser compatible)
</div>
</body>