2017-09-26 53 views
5

我有這個功能很長一段時間,它使我的iframe更改高度點擊,但自上次更新chrome以來,它停止了Chrome瀏覽器的工作。我得到的值爲0,而在瀏覽器或其他平臺上,它的效果很好。任何想法如何使它再次運作?自上次Chrome更新以來,scrollHeight無法工作

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

是否'* .document.documentElement.scrollHeight'在你的代碼的工作? – K3N

+0

是的!謝謝。不知道我錯過了這個。 – yortem

回答

1

你可以試着改變你的引用文件:

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