本文共 2661 字,大约阅读时间需要 8 分钟。
<div id="tabPanel"> <iframe id="tabLeft" width="473" height="230" allowtransparency="true" frameborder="0" scrolling="no" src="../../resource/plugins/twoTabs/interviewOnline!showNewInterivew.action?siteId=562&role=1&videoType=0" style="float:left;"></iframe> <script type="text/javascript"> function reinitIframe(){ var iframe = document.getElementById("tabLeft"); try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.max(bHeight, dHeight); iframe.style.height = height+"px"; }catch (ex){} } window.setInterval("reinitIframe()", 200); </script> <iframe id="tabRight" width="287" height="230" allowtransparency="true" frameborder="0" scrolling="no" src="../../resource/plugins/twoTabs/onlineInvestigate.jsp" style="float:right;"></iframe> <script type="text/javascript"> function reinitIframe(){ var iframe = document.getElementById("tabRight"); try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.max(bHeight, dHeight); iframe.style.height = height+"px"; }catch (ex){} } window.setInterval("reinitIframe()", 200); </script></div>
这样子的话, 在IE7下刷新页面两个IFRAME会窜调, 我这里是第一个IFRAME的内容覆盖了第二个, 然后找了大半天原因, 火狐下是没有问题的, 怀疑是不是IE内核读取方式有问题, 不能在一个DIV里写两个IFRAME, 于是呼把两个IFRAME各自写到自己的DIV里, 问题解决。
<div id="tabPanel">
<div>
<iframe id="tabLeft" width="473" height="230" allowtransparency="true" frameborder="0" scrolling="no" src="../../resource/plugins/twoTabs/interviewOnline!showNewInterivew.action?siteId=562&role=1&videoType=0" style="float:left;"></iframe> <script type="text/javascript"> function reinitIframe(){ var iframe = document.getElementById("tabLeft"); try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.max(bHeight, dHeight); iframe.style.height = height+"px"; }catch (ex){} } window.setInterval("reinitIframe()", 200); </script></div>
<div> <iframe id="tabRight" width="287" height="230" allowtransparency="true" frameborder="0" scrolling="no" src="../../resource/plugins/twoTabs/onlineInvestigate.jsp" style="float:right;"></iframe> <script type="text/javascript"> function reinitIframe(){ var iframe = document.getElementById("tabRight"); try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.max(bHeight, dHeight); iframe.style.height = height+"px"; }catch (ex){} } window.setInterval("reinitIframe()", 200); </script></div>
</div>
转载地址:http://fvalf.baihongyu.com/