1 // retrieve the scroll bar height of the window
2 function getscrolltop (){
3 var scrolltop = 0;
4 If (document.doc umentelement & document.doc umentelement. scrolltop ){
5 scrolltop = document.doc umentelement. scrolltop;
6}
7 else if (document. Body ){
8 scrolltop = Document. Body. scrolltop;
9}
10 return scrolltop;
11}
12
13
14 // take the height of the visible window range
15 function getclientheight (){
16 var clientheight = 0;
17 if (document. Body. clientheight & document.doc umentelement. clientheight ){
18 var clientheight = (document. Body. clientheight <document.doc umentelement. clientheight )? Document. Body. clientheight: document.doc umentelement. clientheight;
19}
20 else {
21 var clientheight = (document. Body. clientheight> document.doc umentelement. clientheight )? Document. Body. clientheight: document.doc umentelement. clientheight;
22}
23 return clientheight;
24}
25
26 // take the actual height of the Document Content
27 function getscrollheight (){
28 return math. Max (document. Body. scrollheight, document.doc umentelement. scrollheight );
29}
Conditions for the scroll bar to reach the bottom: getscrolltop () + getclientheight () = getscrollheight ()