一个简单的高度自适应iframe

在主程序中用以下javascript

 function calcIFrameHeight(id) {
           
          //find the height of the internal page
          var theHeight=
            document.getElementById(id).contentWindow.
              document.body.scrollHeight;
 
          //change the height of the iframe
          document.getElementById(id).height =
              theHeight + 50;
        }

在iframe中用

if (this.frameElement != null) window.parent.calcIFrameHeight(this.frameElement.attributes.id.value);

原文地址:https://www.cnblogs.com/by1455/p/iFrame.html