How to detect scroll position of page using javascript code example
Example 1: checking scroll position with js
let scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
scrollTop = window.pageYOffset || document.documentElement.scrollTop;Code language: JavaScript (javascript)
Example 2: checking scroll position with js
document.documentElement.scrollTop = document.body.scrollTop = 1200;
document.documentElement.scrollLeft = document.body.scrollLeft = 600;Code language: JavaScript (javascript)