当前位置:主页 > 网页前端 > JavaScript代码 >

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

时间:2021-05-08 09:08:24 | 栏目:JavaScript代码 | 点击:

复制代码 代码如下:

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>

您可能感兴趣的文章:

相关文章