JavaScript实现Iframe自适应高度

来源:互联网 发布:淘宝联盟自己买东西 编辑:程序博客网 时间:2024/05/29 18:21

此段代码的功用如题。

<Script>
function resizeIframes()
{
document.getElementById("iframe1").style.height=document.getElementById("iframe1").contentWindow.document.body.scrollHeight+"PX";
}
</script>
<iframe frameborder="0" src="要显示的页面" width="100%" onload="setTimeout(resizeIframes,2000);" align="middle" id="iframe1"></iframe>