Iframe自适应高度

来源:互联网 发布:bluestacks mac地址 编辑:程序博客网 时间:2024/05/16 10:58
  <iframe src="/Home/Default" frameborder="0" id="sysMain" name="sysMain" scrolling="auto" style="padding: 0;                                background-color: #dadfe5;" width="100%" height="880px"></iframe><script type="text/javascript">    function reinitIframe() {        var iframe = document.getElementById("sysMain");        try {            var bHeight = iframe.contentWindow.document.body.scrollHeight;            var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;            var height = Math.max(bHeight, dHeight);            iframe.height = height;        } catch (ex) { }    }    window.setInterval("reinitIframe()", 200); </script> 

 

以上代码可以实现自适应的高度本人已经测试过。


转自:http://www.jb51.net/article/26132.htm

原创粉丝点击