nash01 发表于 2013-2-7 18:35:51

iframe 框架 高度 自适应 问题

js代码<script type="text/javascript">function reinitIframe(frame){var iframe = document.getElementById(frame);try{var bHeight = iframe.contentWindow.document.body.scrollHeight;                         var dHeight =iframe.contentWindow.document.documentElement.scrollHeight;var height = Math.min(bHeight, dHeight);//如果高度小于500的话,则iframe的默认高度是500px;                        if (height < 500) {height = 500;}iframe.height =height;}catch (ex){}}//在前台(界面)每隔200毫秒就刷新一下window.setInterval("reinitIframe('right_content')", 200);                                                                              </script>

html代码

//有一个iframe的id是right_content
<div id="content"><iframe src="" id="right_content" scrolling="no"></iframe></div>
页: [1]
查看完整版本: iframe 框架 高度 自适应 问题