Iframe高度自适应

发表于:2007-06-30来源:作者:点击数: 标签:
iframe width=190 id=test src=gsw. php frameborder=0 scrolling=no/iframe/marqueescript type=text/ java script var iframeids=[test] var iframehide=yes function dyniframesize() { var dyniframe=new Array() for (i=0; iiframeids.length; i++) { if
<iframe width="190" id="test" src="gsw.php" frameborder="0" scrolling="no"></iframe></marquee><script type="text/javascript">
var iframeids=["test"]
var iframehide="yes"
function dyniframesize()
{
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++)
{
if (document.getElementById)
{
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)
dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight;
else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight)
dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;
}
}
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>


原文转自:http://www.ltesting.net