代码改变世界

Iframe自动适应高度

2008-06-11 09:14  Iron  阅读(131)  评论(0编辑  收藏  举报

 

var ifrm = document.getElementById("Iframe_com");

        ifrm.src=url;

        ifrm.className="vis1";

        ifrm.style.height=ifrm.document.body.scrollHeight+1+"px";

又或者

function Iframe_com_onload()

        {

            document.all.Iframe_com.style.height=(Iframe_com.document.body.scrollHeight+50)+"px";

            window.scrollTo(0,0);

        }

<iframe id="Iframe_com"   frameborder="0" width="100%"

     onload="Iframe_com_onload();"></iframe>