您的位置:首页 > 帝国cms教程

帝国cms模板中iframe框架调用高度自适应js方法是什么?

2020-05-14 03:02:36 帝国cms教程 177

用js模板有实现框架自适应高度的方法,代码希望对大家有用。

代码:

<iframeframeborder="0"src="/"class="iframe"frameborder="0"id="test"onload="this.height=100"width="762px"scrolling="no"></iframe><scripttype="text/javascript">functionreinitIframe(){variframe=document.getElementById("test");try{varbHeight=iframe.contentWindow.document.body.scrollHeight;vardHeight=iframe.contentWindow.document.documentElement.scrollHeight;varheight=Math.max(bHeight,dHeight);iframe.height=height;console.log(height);}catch(ex){}}window.setInterval("reinitIframe()",200);</script>


框架的网址可以改成自己的框架地址,也可以放在模板中用标签进行调用视频地址等。

相关推荐