Reload the Current Page Using JavaScript & Keep the Same Scroll Position
How can you programmatically reload the user's current page using JavaScript? And maintain their current scroll position on the page?
You can do that with the reload()
method:
window.location.reload();
This will reload the page and maintain the user's same scroll position. Essentially the same thing a page refresh would do by clicking the reload button in the browser.
Thanks for reading and happy coding!