IFrame自适应高度
来源:互联网 发布:linux自定义命令 编辑:程序博客网 时间:2024/06/05 17:18
想必很多做web开发的人都遇到过iframe内容有滚动条情况,解决方案也是一搜一大堆。自己在遇到一个高人的方案后,稍微做了下调整,支持IE6、IE8、Chrome、Firefox和Opera,感觉比较理想,在此与各位分享,希望共同进步。
内容不多,也不复杂,不做过多说明。前提是需要需要jquery库,在iframe的onload事件中指定调用该函数即可。
function autoHeight(iframe) {var bHeight;var dHeight;var zeroHeight = 10;var initHeight = 450;if($.browser.msie){bHeight = iframe.contentWindow.document.body.scrollHeight;iframe.height = zeroHeight;dHeight = iframe.contentWindow.document.documentElement.scrollHeight;}else if($.browser.mozilla || $.browser.opera){dHeight = iframe.contentWindow.document.documentElement.scrollHeight;iframe.height = zeroHeight;bHeight = iframe.contentWindow.document.body.scrollHeight;}else if($.browser.webkit){iframe.height = zeroHeight;dHeight = iframe.contentWindow.document.documentElement.scrollHeight;bHeight = iframe.contentWindow.document.body.scrollHeight;} else {iframe.height = zeroHeight;dHeight = iframe.contentWindow.document.documentElement.scrollHeight;bHeight = iframe.contentWindow.document.body.scrollHeight;}var height = bHeight > dHeight ? bHeight : dHeight;//alert(bHeight + ":" + dHeight + "=>" + height);if(height < initHeight){height = initHeight;}iframe.height = height;}
- Iframe高度自适应
- iframe 的自适应高度
- 是Iframe高度自适应
- iframe 的自适应高度
- iframe自适应高度
- Iframe自适应高度
- 让IFRAME自适应高度
- Iframe 自适应高度宽度
- iframe自适应高度
- iframe自适应高度
- Iframe自适应高度[摘]
- 让Iframe自适应高度
- IFRAME自适应高度
- iframe自适应高度[转]
- iframe自动自适应高度
- iframe 自适应高度
- Iframe自适应高度
- iframe自适应高度
- c64x+ DSP/BIOS硬件中断的配置
- 文件操作
- Io包下的其他对象
- Java流与文件操作
- Qt+VS2005 LNK 2019 LNK2001 问题解决方案
- IFrame自适应高度
- WPF 几行代码实现窗体毛玻璃效果(Aero Glass)
- 缓冲字符流
- java并发编程--线程池初步
- 字节流
- (转)android面试题
- Cannot find the class file for javax.servlet.ServletContext.
- 怎样花两年时间去面试一个人-转自刘未鹏的博客
- 记win7下 硬盘安装ubuntu11.04