首页 > 语言 > JavaScript > 正文

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

2024-05-06 14:29:10
字体:
来源:转载
供稿:网友

代码如下:
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>

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

图片精选