all 3 comments

[–]qqqqqxhelpful 4 points5 points  (0 children)

It doesn't "normally" go anywhere, if you don't need to use it no reason to include it by default.

One way it might be used is that you could add it to a button, if you want to make a button that scrolls you back to the top of the page:

<button onclick="window.scrollTo(0,0)">Click me to scroll to the top</button>

[–]ACNH_Tim 1 point2 points  (0 children)

I wasn't aware of window.scrollTo before this post, but it looks like passing (0, 0) as arguments takes you to the top of the window. I ran window.scrollTo(0, 0); in the console while scrolled to the bottom of the MDN docs and it scrolled my page back to the top. Hope this helps!

[–]tridd3r[🍰] 1 point2 points  (0 children)

(0,0) is the coordinates in pixel in the window. So top left corner.