Using the browser goBack function in "Littlecloset" template

<button onclick=“goBack()”>Go Back</button>
<script>
function goBack() {
window.history.back();
}
</script>

When you press the button or even hit the browser back button, the page goes back to the previous page and page position, but only for a moment, then it scrolls to the top of the page. Is there a way to stop the page from scrolling to the top. It is when the product.php page re-calls the category.php page. If I have 500 products and am viewing product 200, I want to return to the same spot on the page. Is there something in you script that over rides the goBack() function?

Thanks Rick

PLease don’t duplicate tickets:

https://colorlibsupport.com/t/browser-back-button-in-little-closet-template/