0
I have a Javascript function that refreshes my page every 15 minutes and I’m trying to get the last position of the scroll bar before the refresh with the jQuery command.
$(window).scrollTop();
Refresh function:
var $myVar = setInterval(myTimer, 900000);
function myTimer() {
console.log(scrollPosition);
loadHs();
}
Whenever my page is reloaded it already returns me the value zero, then I would like to rescue the last value as I scroll and set this value rescued after the refresh so that it returns to the previous position.
You’ll need to cache the current value of the scroll to be able to redeem after the page refresh.
– user3688182
That line
localStorage.setItem("timer", true)
is why?– Sam
@Sam this line is no longer part of my code .
– Gabriel Silva