0

I am trying to automate the scrolling down of the webpage using the following JS code

window.scrollTo(0,document.body.scrollHeight);

However, instead of scrolling down the page, it is scrolling up.

Webpage in question is - https://www.zeekbeek.com/OSBA/Search-Results#profession=Lawyers&region=OH

Can someone kindly check what's going wrong here

pb_ng
  • 341
  • 4
  • 17

2 Answers2

0

The problem will be seen only when the DOM is updated by ajax request or some other javascript. Otherwise, it's working. I think while updating DOM you should use jquery live

$( selector ).live( events, data, handler );

update the DOM through the live method. I think that's the problem

0

Your code should be working fine.

Check out the demo below

var btn = document.querySelector('button');

btn.addEventListener('click', function(){
window.scrollTo(0,document.body.scrollHeight);
});
.top{
  height: 500px;
  background: orangered;
}

.bottom{
  margin-top: 30px;
  height: 300px;
  background: grey;
}
<button> Scroll down </button>
<div class="top"> </div>
<div class="bottom"> </div>
Abk
  • 1,669
  • 1
  • 17
  • 25