line 216の
doc.body.offsetHeight
の部分を
(doc.body.offsetHeight || doc.body.scrollHeight)
にしてみる
または
doc.body.scrollHeight
とかにしてみる