Jump to content

Page Returning to Where it was after back arrow

Recommended Posts

Hello, I have had code that has worked for years where when you hit the back arrow you return to where you were on the scroll. It's important with my site, especially on mobile. The back arrow is returning you to the top of the page rather than where you left off. I remember i got code to insert. I am also not sure why it suddenly stopped working.

Link to comment
  • Replies 10
  • Views 524
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

If the back button is to a specific page section, have you tried using an anchor? 

/* Anchor on the page section just above the item you want to target */<span id="mything"></span>

And on the back button the link is ../#mything

Link to comment

SS is making changes all the time. Perhaps a change has rendered your code inoperable.

Please post the URL for a page on your site where we can see your issue.

A link to the backend of the your site won’t work for us, i.e. a url that contains /config/.

Please set up a site-wide password, if your site is not public and you've not already done so.

Post the password here.

Adding a site-wide password does not allow anyone to alter your site. It only allows those with the password to see your site.

Please read the site-wide password and how to share a link documentation to understand how they work.

We can then take a look at your issue.

You may find How to post a forum question post useful.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

I had to upgrade my plan to be able to unlock the code injector. Now I just need code that will do what it did before. Here is the code now that I can copy/paste:

<script type="text/javascript">
  function refreshPage () {
      var page_y = document.getElementsByTagName("body")[0].scrollTop;
      window.location.href = window.location.href.split('?')[0] + '?page_y=' + page_y;
  window.onload = function () {
      setTimeout(refreshPage, 3600000);
      if ( window.location.href.indexOf('page_y') != -1 ) {
          var match = window.location.href.split('?')[1].split("&")[0].split("=");
          document.getElementsByTagName("body")[0].scrollTop = match[1];

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.