iframe框架调用高度自适应方法

iframe框架调用高度自适应方法

来源:帝国CMS模板网 作者:帝国CMS教程 时间:2016-05-23
浏览:3.3千+ 收藏 点赞(14)
简介: 以下代码加入到你想加的帝国cms模板即可iframe frameborder= src=http:www.daixiao360.cn/ clas=iframe frameborder= id=test onload=this.height=100 width=762px

以下代码加入到你想加的帝国cms模板即可

<iframe frameborder="0" src="http://www.daixiao360.cn/" class="iframe" frameborder="0" id="test" onload="this.height=100" width="762px"  scrolling="no"></iframe>
<script type="text/javascript">
function reinitIframe(){
var iframe = document.getElementById("test");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
console.log(height);
}catch (ex){}
}
window.setInterval("reinitIframe()", 200);
</script>
帝国CMS模板网 帝国CMS模板网(www.daixiao360.cn)长期承接帝国CMS模板定制,帝国CMS仿站,帝国CMS采集规则,帝国CMS插件,帝国CMS二次开发。