<strong>实现原理:</strong>加载index.htm时候,每隔1秒钟自动调用脚本刷新框架页面代码 <br><strong>代码优点:</strong>只需要设置index.html框架页面中的脚本,调用加载的子页面中不需要设置任何代码。 <br>index.htm代码如下: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="50596" class="copybut" id="copybut50596" onclick="doCopy('code50596')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code50596"> <br> <br> <br> <br><title>首页</title> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br> <br> <br><div style="float: left; width: 740px; height:auto; border: 1px #808080 Solid; margin: 5px 0px 5px 10px;overflow: hide"> <br><iframe name="ifr_obj" id="ifr_obj" src="%E8%BF%99%E9%87%8C%E5%B5%8C%E5%A5%97%E5%85%B6%E5%AE%83%E9%A1%B5%E9%9D%A2%E5%9C%B0%E5%9D%80%E6%88%96%E8%80%85%E6%96%87%E4%BB%B6%E5%90%8D" frameborder="0" width="100%" scrolling="no" title="框架页面"></iframe> <br> </div> <br> <br><script language="javascript" type="text/javascript"> <BR>function initIframeHeight() { <BR>try { <BR>var iframe = document.getElementById("ifr_obj"); <BR>if (iframe != null) { <BR>if (iframe.contentWindow.document.body != null) { <BR>var bHeight = iframe.contentWindow.document.body.scrollHeight; <BR>var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; <BR>var height = Math.max(bHeight, dHeight); <BR>iframe.height = height; <BR>} <BR>} <BR>} <BR>catch (ex) { <BR>alert("加载框架页面高度时出错"+ex.toString()); <BR>} <BR>} <BR>window.setInterval("initIframeHeight()", 1000); <BR></script> <br> <br> </div>