"Go back" location problem with hash

Hi,

I have a website with a lot of products. I’m using anchor IDs to navigate to different sections, both within the same page and from other pages.

Use case:

Problem:
When I navigate back with the browser button or a link, using this code

var Webflow = Webflow || [];
Webflow.push(function() {
  $('a.product-back-link').click(function() {
    history.back(1); return false;
  });
});

it takes me back to the previous page and then animates back to #section. This is pretty annoying if you’ve scrolled far from the section.

I do understand why this is happening. But, is there a way to take me back to the previous page and stay on the last location, as it would do if I wouldn’t use the anchor ID’s?

My English is awful, so I really hope anyone understands :sweat_smile: I would really appreciate any help. Thank you, guys!

Video https://drive.google.com/file/d/14-HbuFgSeYkUuVOcrXXadu6M6TUi2YWa/view?usp=sharing

Possible solution here How to remove the hash from window.location (URL) with JavaScript without page refresh? - Stack Overflow

1 Like

Wow! Thank you. I will have a look and see if I come up with something.