iframe自适应高度问题
2015-05-18 22:25
267 查看
正在踌躇的时候发现下面的这段代码,终于得意解决。苦于对js没有足够的熟悉,代码中的具体方法参数还得继续学习,感谢提供代码的朋友。
function SetCwinHeight()
{
var cwin=document.getElementById("cwin");
if (document.getElementById)
{
if (cwin && !window.opera)
{
if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
cwin.height = cwin.contentDocument.body.offsetHeight;
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight;
}
}
}
<iframe width="778" align="center" height="200" id="cwin" name="cwin" onload="Javascript:SetCwinHeight(this)" frameborder="0" scrolling="no"></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;
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight;
}
}
}
引用时
onload="javascript:SetCwinHeight(this)"
function SetCwinHeight()
{
var cwin=document.getElementById("cwin");
if (document.getElementById)
{
if (cwin && !window.opera)
{
if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
cwin.height = cwin.contentDocument.body.offsetHeight;
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight;
}
}
}
<iframe width="778" align="center" height="200" id="cwin" name="cwin" onload="Javascript:SetCwinHeight(this)" frameborder="0" scrolling="no"></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;
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document.body.scrollHeight;
}
}
}
引用时
onload="javascript:SetCwinHeight(this)"
相关文章推荐
- 两段超简单jquery代码解决iframe自适应高度问题(不用判断浏览器高度)
- iframe自适应高度问题
- iframe跨域 自适应高度的问题
- iframe自适应高度完美版解决DOM元素高度变化问题
- 兼容多浏览器的iframe高度自适应问题
- iframe 自适应高度问题解决方法
- 关于iframe的自适应高度问题
- JavaScript 处理Iframe自适应高度的问题
- Iframe自适应页面高度问题的最简单最适用的解决办法
- iframe 子页面自适应高度问题
- 关于iframe自适应高度,解决一个iframe动态改变url,改变页面同时解决高度自适应问题
- EasyUI中iframe嵌入页面,包含datagrid数据动态绑定,页面内容的高度自适应问题
- iframe自适应内层页面高度,可响应页面中折叠点击事件,以及实现跨域的问题解决方案
- iframe 自适应高度的问题(jquery控制)
- jquery ajax应用中iframe自适应高度问题解决方法
- iframe通信问题及自适应高度
- 解决父窗体内Iframe高度自适应问题
- iframe跨域自适应高度问题的解决方法
- 【开发过程问题汇总系列】【iframe自适应高度】兼容 FireFox和IE内核的浏览器
- dh: 实现iframe 自适应高度的问题(初始化和动态加载数据的时候)