虚位以待(AD)
虚位以待(AD)
首页 > 网页特效 > JavaScript > Iframe 自动适应页面的高度示例代码

Iframe 自动适应页面的高度示例代码
类别:JavaScript   作者:码皇   来源:互联网   点击:

这篇文章主要介绍了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>

相关热词搜索: iframe 自适应 页面高度