0

Do any of you know why scrollTo and scrollBy methods in Chrome are not working. In other browsers eg Firefox it works. I can fix the issue by adding a setTimeout. An eventListener like load or DOMContentloaded is not working. Thanks and VG.

<script>
scrollTo(0,200); // does not work
setTimeout(function a() {scrollTo(0,200);},1); //works.
</script>
mtx
  • 1,196
  • 2
  • 17
  • 41
Kat
  • 61
  • 3
  • This might help you, https://stackoverflow.com/a/15694294/3511390 give it a try. – Ray Apr 08 '22 at 17:10

1 Answers1

0

According to Mark Ni's Comment in JavaScript issue with scrollTo() in Chrome issue:

Chrome is so fast that your scrollTo() action fires before Chrome's default scroll to html anchor event.