2011-11-15 45 views

回答

1

這裏是做一個函數:

function getDocumentHeight() { 
    return Math.max(
     Math.max(document.body.scrollHeight, document.documentElement.scrollHeight), 
     Math.max(document.body.offsetHeight, document.documentElement.offsetHeight), 
     Math.max(document.body.clientHeight, document.documentElement.clientHeight) 
    ); 
} 
+1

你爲什麼讓3個冗餘Math.max電話? – Esailija

+0

這似乎並不適用於Mobile Safari ---對於應該具有〜900像素高度的文檔,此函數返回358px。 – derrylwc

+0

編輯:此功能工作。在我急於測試的時候,我已經在DOM完成渲染之前將這個調用放在了DOM中。謝謝! :) – derrylwc

相關問題