iframe自适应高度
2016-12-07 15:42
411 查看
function setIFrameHeight(iframe){
var ifm_content = document.getElementById("conFrame");
ifm_content.height = "500px";//默认设置为500px
var heightContent = "500px";
var subContent = document.frames ?document.frames["conFrame"].document : ifm_content.contentDocument;
if (iframe == "content") { //如果传入Ifame Id 等于content 重新给iframe赋值高度
heightContent =Math.max(subContent.body.scrollHeight, subContent.documentElement.scrollHeight);
ifm_content.height =heightContent;
}
}
实例说明:
我的Html中有一个Iframe 用法如下:
<iframeid="conFrame"
src="a.html"
frameborder="0"scrolling="no"
width="100%"height="500px"
onload="setIFrameHeight('content');"></iframe>
var ifm_content = document.getElementById("conFrame");
ifm_content.height = "500px";//默认设置为500px
var heightContent = "500px";
var subContent = document.frames ?document.frames["conFrame"].document : ifm_content.contentDocument;
if (iframe == "content") { //如果传入Ifame Id 等于content 重新给iframe赋值高度
heightContent =Math.max(subContent.body.scrollHeight, subContent.documentElement.scrollHeight);
ifm_content.height =heightContent;
}
}
实例说明:
我的Html中有一个Iframe 用法如下:
<iframeid="conFrame"
src="a.html"
frameborder="0"scrolling="no"
width="100%"height="500px"
onload="setIFrameHeight('content');"></iframe>
相关文章推荐
- iframe高度自适应。
- 完美实现跨域Iframe高度自适应【Iframe跨域高度自适应解决方案】
- 完美实现跨域Iframe高度自适应
- iframe 跨域自适应高度的解决方案
- 使用iframe自适应宽度和高度
- 基于jquery的兼容各种浏览器的iframe自适应高度的脚本
- iframe实现自适应高度
- Iframe自适应高度绝对好使的代码 兼容IE,遨游,火狐
- 如何使iframe自适应高度和宽度
- layer.open iframe高度自适应,屏幕居中的解决方案
- 如何实现iframe(嵌入式帧)的自适应高度
- 如何实现iframe(嵌入式帧)的自适应高度
- iframe自适应高度js
- Html iframe 窗口自适应内容高度
- jQuery设置iframe的高度根据页面内容自适应
- 关于IFRAME 自适应高度的研究
- iframe自适应高度
- 让IFRAME的高度随着里面的内容增加而加/IFRAME自适应高度
- IFRAME自适应高度