Retain scrollbar position even after reloading using javascript
We can use session storage to store the position then get back to the position when the page is reloaded, like this:
It's often frustating to scroll down a page through navigation. The Below code makes it simple.
You can use external libraries such as ScrollSpy to acheive, here is a simple workaround in jQuery..
$(window).scroll(function() {
sessionStorage.scrollTop = $(this).scrollTop();
});
$(document).ready(function() {
if (sessionStorage.scrollTop != "undefined") {
$(window).scrollTop(sessionStorage.scrollTop);
}
});