get window scroll position

var top  = window.pageYOffset || document.documentElement.scrollTop,
    left = window.pageXOffset || document.documentElement.scrollLeft;

I'm hoping to find a way to get the current viewable window's position (relative to the total page width/height) so I can use it to force a scroll from one section to another. However, there seems ...

BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. Get the top and left position of the window
2. Get the scroll position of the window
3. Get the top and left position of the div
4. Subtract the scroll position from the top and left position
5. Add the scroll position to the

Snippet By Tony Lea

·

Created October 19th, 2021

·

Report Snippet