2009-07-07 116 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