Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 2
LIGHTBOXQUESTION

URGENT: How to return to the same scroll position when using browser's back button?

Question

Hello, can you please help?
I would simply like to have my site do the following:

1. When you click the back button in a browser, it takes you back to where you were on the previous page. Currently, it takes you back to top of page, which is frustrating if you were 10 images down in a gallery or on mobile. I am okay with a load time... 🙂

Is this possible on Squarespace? Example can be found here:
https://www.nicholaskonert.com/art

Thank you for your help and support.

Share this post


Link to post

5 answers to this question

Recommended Posts

  • 0

I am having the same issue! 

I have many images with click through links, and I do not have them opening in a new window. However, when clicking the "back" button in my browser, it returns to the previous page but scrolled all the way to the bottom. Very annoying to find your place again.

Attached are images describing this, and here is the site: https://kristinspiewak.com/#/furniture/

Any solutions to this??

squarespace-issue.jpg

Share this post


Link to post
  • 0

I am looking for an answer to this annoying issue as well !!!  Seems to me to be a fairly fundamental web site requirement.

Share this post


Link to post
  • 0

Did anyone work out how to do this? I would also like the know the answer!

Thanks

Share this post


Link to post
  • 0

Hey friends, 

Here's a snippet of code that I use to save the scroll position. I use it when a user has navigated away from a long index page and I want them to return to the same place.

Note, for an index, you must add it in the code injection for the INDEX, not the page section. 

<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, 35000);
      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];
      }
  }
</script>

Let me know if this helps!

Share this post


Link to post

Create an account or sign in to comment

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


×
×
  • Create New...