1

Browser dev tools is an awesome tool. I want to know whether user have reached the end of the page from Browser Console. When I am trying to do this using javascript, it is saying "undefined"

How should we deal with Ajax loaded Page? How to find out whether user have reached the end of AJAX loaded page?

RecklessSergio
  • 806
  • 3
  • 10
  • 34
  • possible duplicate of [Determining when scrolled to bottom of a page with Javascript](http://stackoverflow.com/questions/2817042/determining-when-scrolled-to-bottom-of-a-page-with-javascript) – Taylan Aydinli Nov 20 '13 at 10:56
  • Please post a code sample of how you're doing this currently. – Taylan Aydinli Nov 20 '13 at 10:56

1 Answers1

1

Try this code in your console : ( Source : see the link)

setInterval(function(){
  var totalHeight;
  var currentScroll;
  var visibleHeight;

  if(document.documentElement.scrollTop){ 
      currentScroll = document.documentElement.scrollTop; 
  }else{ 
      currentScroll = document.body.scrollTop; 
  }

  totalHeight = document.body.offsetHeight;
  visibleHeight = document.documentElement.clientHeight;      

  if (totalHeight <= currentScroll + visibleHeight ){
    console.log('bottom of page');
  } 
 }, 1000);
Community
  • 1
  • 1
Ankit Tyagi
  • 2,381
  • 10
  • 19
  • Hi @Tyagi, It is working. But The page I am trying on is ajax loaded page. Sorry, I should have told this before. So, once all the page is loaded, is there a way to find out whether he have reached the end? – RecklessSergio Nov 20 '13 at 11:20
  • Well try to make a function of this code and call it when page is loaded. – Ankit Tyagi Nov 20 '13 at 11:36
  • Hi Tyagi, I tried. But the problem is, data which is loading at the end of the page is taking sometime. SO, 'bottom of the page' is getting printed till the data is loaded. Is there any other way to figure out? – RecklessSergio Nov 22 '13 at 08:39