iframe自适应高度
来源:互联网 发布:互联网 加大数据 编辑:程序博客网 时间:2024/05/10 02:34
在做项目的过程中,需要用到iframe,但是iframe的高度如果写死的话,它对应的页面高度都得固定,这样不能适应页面内容变化,不太灵活,所以写了以下的方法,根据iframe对应的页面内容来决定iframe的高度。
这个本人测试适应于ie,火狐浏览器。
<iframe src="a.html" id="iframe"
frameBorder="0" marginheight="0" marginwidth="0" width="500px"height="100%" scrolling="no" name="iframe"
onLoad="getHeight()"> </iframe>
function getHeight() {
var ifm = document.getElementById("iframe");//iframe的id
var subWeb = document.frames ? document.frames["iframe"].document
:
ifm.contentDocument;//iframe的name
if (ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight;
}
}
</script>
0 0
- Iframe高度自适应
- iframe 的自适应高度
- 是Iframe高度自适应
- iframe 的自适应高度
- iframe自适应高度
- Iframe自适应高度
- 让IFRAME自适应高度
- Iframe 自适应高度宽度
- iframe自适应高度
- iframe自适应高度
- Iframe自适应高度[摘]
- 让Iframe自适应高度
- IFRAME自适应高度
- iframe自适应高度[转]
- iframe自动自适应高度
- iframe 自适应高度
- Iframe自适应高度
- iframe自适应高度
- SQLite优化
- C++矩阵工具包Eigen使用入门
- 【转】Swift之?和!
- 连接字符串大全
- PAT A 1087. All Roads Lead to Rome (30)
- iframe自适应高度
- JavaScript scrollTo() 函数示例
- --help
- TabHost选项卡的实现(一):使用TabActivity实现
- Android休眠唤醒机制简介(一)
- Swift学习笔记五:循环和条件语句
- 数据隔离
- tomcat源码分析之filter和servlet
- POJ - 3261 Milk Patterns (后缀数组求可重叠的 k 次最长重复子串)