iframe自适应高度,多层嵌套iframe自适应高度的解决方法
2010-12-30 15:30
519 查看
iframe自适应高度,多层嵌套iframe自适应高度的解决方法
在页面无刷新更新方面,虽然现在的ajax很强悍,但是处理代码相对多点。想比之下,iframe就简单多了!处理iframe的自适应宽、高,会经常用到,网上整理了一份,写在这里备用: 一: 单个iframe 高度自适应: <iframe id="mainframe" name="mainframe" width="100%" onload="this.height=mainframe.document.body.scrollHeight" frameborder="0" src="index.htm"></iframe> onload="this.height=mainframe.document.body.scrollHeight" 二: 多层嵌套iframe 高度自适应: A页面的iframe 加载B.php文件: <iframe id="frame_content" src=”B.php“ name="right" width="1003" frameborder="0" scrolling="no" ></iframe> B.php页面又有一个iframe: <iframe width="750" name="rightform" id="rightform" src="KinTimMng_right_init.php" frameborder="0" scrolling="no" onload="this.height=rightform.document.body.scrollHeight;parent.document.getElementById('frame_content').style.height= document.body.scrollHeight + 'px';" ></iframe> 起作用的代码是这句:onload="this.height=rightform.document.body.scrollHeight;parent.document.getElementById('frame_content').style.height= document.body.scrollHeight + 'px';" onload的时候执行了两条js语句: 1、设置当前iframe自己的高度自适应 this.height=rightform.document.body.scrollHeight 2、设置父iframe的高度自适应(注意后面的高度单位px,如果不加单位,firefox下不起作用) parent.document.getElementById('frame_content').style.height= document.body.scrollHeight + 'px' 以上代码在ie firefox3.5下测试通过 |
相关文章推荐
- iframe自适应高度,多层嵌套iframe自适应高度的解决方法
- 多层嵌套iframe 自适应高度的解决方法
- iframe自适应高度,多层嵌套iframe自适应高度的解决方法
- iframe自适应高度,多层嵌套iframe自适应高度的解决方法
- iframe自适应高度,多层嵌套iframe自适应高度的解决方法
- iframe自适应高度解决方法
- asp.net中iframe框架自适应高度的一种解决方法
- Iframe实现跨浏览器自适应高度解决方法
- div ul li 嵌套后解决高度自适应方法
- iframe跨域自适应高度问题的解决方法
- 多层嵌套Iframe的自适应问题解决
- IE8下DIV嵌套出现外层自适应高度(四种解决方法)
- iframe 多层嵌套 无限嵌套 高度自适应
- jquery ajax应用中iframe自适应高度问题解决方法
- HTML篇之CSS样式——div ul li 嵌套后解决高度自适应方法
- 多层嵌套Iframe的自适应问题解决
- 多层嵌套Iframe的自适应问题解决
- div ul li 嵌套后解决高度自适应方法
- iframe自适应高度解决方法 .
- iframe框架高度自适应在兼容模式下(ie7)不兼容的解决方法