<script type="text/javascript">function reinitIframe(){var iframe = document.getElementById("reinitIframe");try{var bHeight = iframe.contentWindow.document.body.scrollHeight;var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;var height = Math.max(bHeight, dHeight);
iframe.height = height;
iframe.width=1001;
//alert(iframe.height);
//document.getElementById('TabContent').style.height=height;}catch (ex){}}window.setInterval("reinitIframe()", 218);</script> <iframe id="reinitIframe" name="ProductViewIframe" src="<%=DefaultSelected %>" style="width:1003px;" scrolling="no" frameborder="0" onload="this.height=218"></iframe>
我使用了上面的代码实现iframe的自适应高度,实现是实现了,但是,滚动条一直在走,页面的高度一直在增加,很不友好,我该怎么让滚动条不走呢?
iframe.height = height;
iframe.width=1001;
//alert(iframe.height);
//document.getElementById('TabContent').style.height=height;}catch (ex){}}window.setInterval("reinitIframe()", 218);</script> <iframe id="reinitIframe" name="ProductViewIframe" src="<%=DefaultSelected %>" style="width:1003px;" scrolling="no" frameborder="0" onload="this.height=218"></iframe>
我使用了上面的代码实现iframe的自适应高度,实现是实现了,但是,滚动条一直在走,页面的高度一直在增加,很不友好,我该怎么让滚动条不走呢?
解决方案 »
- 求java 编写语法分析程序!!!!!!!!!!!
- i=i++到底做了什么?
- 测试BufferedInputStream的mark()和reset()方法,提交文件时会出现Resetting to invalid mark
- 请高手指点,java 中将字符串数组转换为整型数组
- 求点拨一个Java Swing的GUI技术细节.
- 请看过《thinking in java 2nd〉的高手回答一个小问题。
- sos!!! 我要将一长串存成blob???~~^-^~~
- 有没有人用java编过加密算法???
- JAVA控制台输入问题
- 如何将泛型当作参数传递?
- 如何设置回车为快捷键,就像QQ发送消息一样!
- 到底是get提交,还是post提交阿
function resize(id)
{
var height = document.getElementById(id).contentWindow.document.body.scrollHeight;
var width = document.getElementById(id).contentWindow.document.body.scrollWidth; document.getElementById(id).height= (height) + "px";
document.getElementById(id).width= (width) + "px";
}<iframe id="content" name="content" src="section.htm" scrolling="no" frameborder="0" border="0" onLoad="resize('content')"></iframe>=====这个是我以前用过的一段重设iframe大小的代码,去掉重设宽度的部分就行了,希望对你有帮助。
对比一下,你用的那段代码中的这一句:
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
可能取得了某父元素的高度,结合max那句造成了无限循环。