您现在的位置: 万盛学电脑网 >> 程序编程 >> 脚本专题 >> javascript >> 正文

Iframe 自动适应页面的高度示例代码

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 这篇文章主要介绍了Iframe如何自动适应页面的高度,需要的朋友可以参考下

   代码如下: function SetCwinHeight(obj) {  var cwin = obj;  if (document.getElementById) {  if (cwin && !window.opera) {  if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)  cwin.height = cwin.contentDocument.body.offsetHeight + 30;  else if (cwin.Document && cwin.Document.body.scrollHeight)  cwin.height = cwin.Document.body.scrollHeight + 30;  }  }  }     代码如下: <iframe id="IframeId_help" scrolling="no" onload="Javascript:SetCwinHeight(this)"  width="670px" style="border: 0px" frameborder="0"></iframe>