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

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

7 answers to this question

Recommended Posts

  • 1

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

Where is back button?


You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan. I work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. There are so many questions every day so I can't answer them all at once, I will try to answer them in the next few days.

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
  • 0
On 6/18/2020 at 2:08 PM, colin.simmons said:

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!

I'm confused what I'm supposed to do with this code. Where do I paste it? In the "Code Injection" section?

Share this post


Link to post
  • 0
On 9/16/2020 at 11:50 PM, kylejcho said:

I'm confused what I'm supposed to do with this code. Where do I paste it? In the "Code Injection" section?

Add to Home > Settings > Advanced > Code Injection > Footer


You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan. I work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. There are so many questions every day so I can't answer them all at once, I will try to answer them in the next few days.

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...