iframe 高度自适应
2009-09-29 19:27
204 查看
根据iframe 内容的滚动条高度自动调整iframe 的高度。
1、iframe 的设置:
<iframe width="100%" id="autoHeightIframe"
onload="Javascrīpt:setIframeHeight(this)" frameborder="0" scrolling="no">
</iframe>
2、JavaScript 脚本设置:
<script>
//自动调整 iframe 高度
function setIframeHeight(iobj) {
var win = iobj;
if (document.getElementById("autoHeightIframe")) {
if(win && !window.opera) {
if (win.contentDocument && win.contentDocument.body.offsetHeight) {
win.height = win.contentDocument.body.offsetHeight;
}else if (win.Document && win.Document.body.scrollHeight) {
win.height = win.Document.body.scrollHeight;
}
}
}
}
</script>
1、iframe 的设置:
<iframe width="100%" id="autoHeightIframe"
onload="Javascrīpt:setIframeHeight(this)" frameborder="0" scrolling="no">
</iframe>
2、JavaScript 脚本设置:
<script>
//自动调整 iframe 高度
function setIframeHeight(iobj) {
var win = iobj;
if (document.getElementById("autoHeightIframe")) {
if(win && !window.opera) {
if (win.contentDocument && win.contentDocument.body.offsetHeight) {
win.height = win.contentDocument.body.offsetHeight;
}else if (win.Document && win.Document.body.scrollHeight) {
win.height = win.Document.body.scrollHeight;
}
}
}
}
</script>
相关文章推荐
- IFRAME 自适应高度
- iframe 自适应高度最简单代码
- iframe 自适应高度问题解决方法
- Iframe高度自适应(兼容IE/Firefox、同域/跨域)[转]
- JS 关于浏览器之间 scrollHeight offsetHeight (比如 iframe自适应高度时...)
- iframe高度自适应内容
- js控制iframe自适应高度
- jquery 实现iframe 自适应高度
- [转载]再谈iframe自适应高度
- 解决IFrame高度自适应
- 兼容多浏览器的iframe自适应高度(ie8 、谷歌浏览器4.0和 firefox3.5.3)
- 【转载】iframe自适应高度详解(转帖)
- iframe自适应高度的多种方法方法小结
- iframe自适应高度
- iframe自适应高度,多层嵌套iframe自适应高度的解决方法
- 网页布局中iframe高度自适应问题总结
- iframe自适应高度 iframe
- iframe自适应高度
- 实现iFrame自适应高度,原来很简单!
- Iframe自适应高度