线坠儿 2019-12-02 09:40 采纳率: 100%
浏览 571
已采纳

页面上多个iframe,如何执行自适应高度

<script type="text/javascript">
function reinitIframe(){
var iframe = document.getElementById("iframeid");
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>

这个代码只能执行一个

  • 写回答

2条回答 默认 最新

  • xd_zhaoqi 2019-12-02 09:44
    关注

    是因为你获取的是id嘛,因为id标签不可以设置多个。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?