首页 > 语言 > JavaScript > 正文

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

2024-05-06 16:01:44
字体:
来源:转载
供稿:网友
这篇文章主要介绍了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 scrolling="no"
width="670px" frameborder="0"></iframe>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选