My site auto scrolls to top when press back from product page

Hi, when on my website through an Instagram link such as in the bio or from an advert. When you click back after looking at a product it takes you back to the top of the product page. Can someone help me stop this please?

When you click back from a product page and it scrolls to the top it’s usually because the browser refreshes the page state
To fix this you can use JavaScript to remember the scroll position

  • Go to your Shopify admin panel
  • Navigate to Online Store > Themes.
  • Click on Actions > Edit Code for your active theme
  • In the left-hand sidebar, open the theme.liquid file located under Layout
  • Scroll to the bottom and paste this JavaScript code right before the closing tag
  • Click Save.

Hope this helps

Hi, thank you for getting back to me. I have tried this and unfortunately I am still having the same problem when pressing the back arrow on my website it scrolls back to the top of the page. Can you take a further look please?

can you please share your store link ? @Grab_The_Brand

1 Like

www.grabthebrand.co.uk

The problem only seems to happen when viewing the site through a website link on Instagram. The Instagram account is @grabthebrand and the link is in the bio.

Thank you

Hi, are you able to help me please?

Hey @Grab_The_Brand
Can you send me a screencast of you reproducing the problem?
Send it to me at this email address and I’ll help you solve it

@Grab_The_Brand Thankx fer take me back , let me try

@Grab_The_Brand Can you please share theme file or accessible it for me

1 Like

How do I do that?

1 Like

hello, not sure i see a solution, can you help pls? only on mobile version, when you click the back button after reviewing an item, it takes you all the way to top of main page which is annoying. thank you !