Javascript iFrame大小问题

时间:2012-03-05 21:51:33

标签: javascript

我有这个片段可以帮助我调整iFrame的大小:

<script language="JavaScript">
<!--
function autoResize(id){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }

    document.getElementById(id).height= (newheight) + 30 + "px";
    document.getElementById(id).width= (newwidth) + "px";
}
//-->
</script>

       <iframe src="/forum" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>

它适用于负载。但是,当我浏览iFramed网站时,它保持与页面加载时相同的尺寸。因此,如果iFrame中的内容发生变化,高度根本不会改变..

如何解决此问题?我尝试过onmouseover,onclick,onblur等等......没什么..

有没有办法让它调整iFrame的大小而不是onLoad但是当iFrame更改内容时?

由于

0 个答案:

没有答案
相关问题