首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

iframe 框架 高度 自适应 有关问题

2012-11-22 
iframe 框架 高度 自适应 问题js代码script typetext/javascriptfunction reinitIframe(frame){var i

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>


热点排行