top of window scroll code example
Example 1: javascript get scroll position
function getYPosition(){
var top = window.pageYOffset || document.documentElement.scrollTop
return top;
}
Example 2: js scrollto
element.scrollTo(x, y);
window.scrollTo(x, y);
element.scrollTo({
top: 100,
left: 100,
behavior: 'smooth'
});