無廢話,網上不少文章一下寫了幾種實現方式,代碼短點的呢用不了,長點的呢眼睛都看花javascript
下面的代碼在火狐、IE上正常java
- <script type="text/javascript">
- function reinitIframe(){
- var iframe = document.getElementById("mainFrame");
- 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);
- </script>
轉載自http://www.jb51.net/article/26132.htm,Markspa