iframe自适应高度完美版解决DOM元素高度变化问题-创新互联
来源:http://www.sosuo8.com/article/show.asp?id=2917
分享题目:iframe自适应高度完美版解决DOM元素高度变化问题-创新互联
转载来于:http://scpingwu.com/article/ceeeio.html

如果iframe里面内容不进行DOM操作,可以使用这种最简单的方式:
反之,在iframe页里进行DOM操作,或者表格展现(表格展现如果挤压会改变高度)可以使用下面的方法
JavaScript复制代码- function reinitIframe() {
- var iframe = document.getElementById("iframe");
- try {
- var bHeight =iframe.contentWindow.document.body.scrollHeight;
- var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
- var height = Math.max(bHeight, dHeight); iframe.height = height;
- } catch (ex) { }
- }
- window.setInterval("reinitIframe()", 200);//定时去检查iframe的高度,这样保证时时都是自动高了
分享题目:iframe自适应高度完美版解决DOM元素高度变化问题-创新互联
转载来于:http://scpingwu.com/article/ceeeio.html