2009-07-07 149 views

回答

2

我逃脫了document.body.scrollHeight使

document.body.scrollHeight = window.pageYOffset + screen height in pixels 

頁面(在Android)結束。

14

替代window.scrollMaxY

document.documentElement.scrollHeight - document.documentElement.clientHeight 

給出下DOCTYPE XHTML 1.0過渡相同的結果用window.scrollMaxY IE7,IE8,FF3.5,Safari瀏覽器4,歌劇10,谷歌瀏覽器3。

+0

謝謝你的好先生。我很想知道是否有任何缺點使用這種方法。我只是在Chrome/Firefox中測試它,它的工作原理! – swajak 2011-06-06 23:17:16

3

兩年後......

function getScrollMaxY(){ 

var innerh; 

if (window.innerHeight){ 
    innerh = window.innerHeight; 
}else{ 
    innerh = document.body.clientHeight; 
} 

if (window.innerHeight && window.scrollMaxY){ 
    // Firefox 
    yWithScroll = window.innerHeight + window.scrollMaxY; 
} else if (document.body.scrollHeight > document.body.offsetHeight){ 
    // all but Explorer Mac 
    yWithScroll = document.body.scrollHeight; 
} else { 
    // works in Explorer 6 Strict, Mozilla (not FF) and Safari 
    yWithScroll = document.body.offsetHeight; 
} 
return yWithScroll-innerh; 
} 
0
x = document.body.clientHeight; 
console.log(x ,"Cline HEight");  

xx = window.innerHeight; 
console.log(xx, "Inner Height"); 

xxx = document.body.scrollHeight 
console.log(xxx, "scrollHeight"); 

xxxx = window.scrollMaxY; 
console.log(xxxx, "scrollMaxY for IE"); 


xxxxx = document.body.offsetHeight; 
console.log(xxxxx, "offsetHeight"); 

xxxxxx= document.body.scrollTop; 
console.log(xxxxxx, "scrollTop");strong text