我使用此功能已有很长时间,它使iframe的点击高度发生了变化,但是自chrome的上一次更新以来,它停止在chrome上运行。我得到的值为0,而在资源管理器或其他平台上,它的效果很好。任何想法如何使其再次起作用?

function calcHeight() {
        var the_height = document.getElementById('resize').contentWindow.document.body.scrollHeight;
        window.alert(the_height);
        document.getElementById('resize').height= the_height;
}

最佳答案

您可以尝试将引用文档的方式更改为:

var the_height =
  document.getElementById('resize').contentWindow.document.documentElement.scrollHeight;

07-24 09:50
查看更多