加入收藏 | 设为首页 | 会员中心 | 我要投稿 应用网_丽江站长网 (http://www.0888zz.com/)- 科技、建站、数据工具、云上网络、机器学习!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

iframe框架调用高度自适应技巧

发布时间:2021-11-26 16:09:38 所属栏目:PHP教程 来源:互联网
导读:01 iframe frameborder=0 src=http://www.daixiao360.cn/ class=iframe frameborder=0 id=test onload=this.height=100 width=762px scrolling=no/iframe 02 script type=text/javascript 03 function reinitIframe(){ 04 var iframe = document.getElementBy
01
<iframe frameborder="0" src="http://www.daixiao360.cn/" class="iframe" frameborder="0" id="test" onload="this.height=100" width="762px"  scrolling="no"></iframe>
02
<script type="text/javascript">
03
function reinitIframe(){
04
var iframe = document.getElementById("test");
05
try{
06
var bHeight = iframe.contentWindow.document.body.scrollHeight;
07
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
08
var height = Math.max(bHeight, dHeight);
09
iframe.height = height;
10
console.log(height);
11
}catch (ex){}
12
}
13
window.setInterval("reinitIframe()", 200);
14
</script>
 

(编辑:应用网_丽江站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读