determine where scroll position in javascript code example
Example 1: javascript get scroll position
function getYPosition(){
var top = window.pageYOffset || document.documentElement.scrollTop
return top;
}
Example 2: checking scroll position with js
let scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
scrollTop = window.pageYOffset || document.documentElement.scrollTop;Code language: JavaScript (javascript)