Cross browser scrollTop


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // found at http://stackoverflow.com/questions/871399/cross-browser-method-for-detecting-the-scrolltop-of-the-browser-window
  2. function getScrollTop(){
  3. if(typeof pageYOffset!= 'undefined'){
  4. //most browsers
  5. return pageYOffset;
  6. }
  7. else{
  8. var B= document.body; //IE 'quirks'
  9. var D= document.documentElement; //IE with doctype
  10. D= (D.clientHeight)? D: B;
  11. return D.scrollTop;
  12. }
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.