展会信息港展会大全

js实现Iframe高度自动适应页面的代码
来源:互联网   发布日期:2016-01-28 12:54:51   浏览:2258次  

导读:这篇文章主要介绍了Iframe如何自动适应页面的高度,需要的朋友可以参考下代码如下:function SetCwinHeight(obj) {var cwin = obj;if (document getElementById) {if (cwin !window opera) {if (cw ...

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

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港