Posted By

uberdragon on 05/10/11


Tagged


Versions (?)

getScrollHeight()


 / Published in: JavaScript
 

  1. function getScrollHeight() {
  2. var maxDisplacement=0;
  3.  
  4. window.scrollTo(0,10000000);
  5.  
  6. if( typeof self.pageYOffset!='undefined' )
  7. maxDisplacement=self.pageYOffset;
  8. else if( document.compatMode && document.compatMode != 'BackCompat' )
  9. maxDisplacement=document.documentElement.scrollTop ;
  10. else if( document.body && typeof(document.body.scrollTop)!='undefined' )
  11. maxDisplacement=document.body.scrollTop;
  12.  
  13. window.scrollTo(0,0);
  14. return maxDisplacement;
  15. }
  16.  
  17. window.onload=function(){
  18. var h = getScrollHeight();
  19. alert(h);
  20. }

Report this snippet  

You need to login to post a comment.