自上次Chrome更新后,scrollHeight无效

yor*_*tem 5 javascript google-chrome

我有这个功能很长一段时间,它点击了我的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;
}
Run Code Online (Sandbox Code Playgroud)

小智 1

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

var the_height =
  document.getElementById('resize').contentWindow.document.documentElement.scrollHeight;
Run Code Online (Sandbox Code Playgroud)