Reload website upon clicking browser back button and keep scroll position?


Problem: I have a website with a large feed, people click links to my articles, being directed to them. When they click back, to return to the feed, i want the website to be refreshed, which i currently achieve with this custom code in the header:

(function () {
	window.onpageshow = function(event) {
		if (event.persisted) {

It reloads the website whenever someone uses the back button in the browser, which is just what i want. The problem is: i would like the scroll position of the website to be kept as well, so my readers don’t have to scroll down again, after returning to the feed.

This issue is especially prevalent on the safari browser, which most iPhone users use, which in turn is most of my readership.

I’d be delighted if anyone of you has any suggestions to fix this issue!

c getty

Maybe this helps? javascript - Refresh Page and Keep Scroll Position - Stack Overflow

This, sadly, does not help - implementing it into the head section, now testing the website: the page does not reload upon pressing the back button…