How to disable the automatic scroll of browser on back navigation
I have a Product Listing Page and Product Detail Page. The products in PLP are listed dynamically through graphql. The scenario is when a product is clicked on the PLP it takes me to PDP and when browser’s back button is clicked, it takes me back to PLP. Now, as we know browsers have default scroll set for back navigation to that part of the page till where it was last scrolled to. So, same is happening here, when I click on back button from PDP and it lands on PLP,the page is landed on the part where it was last scrolled to but in some cases where internet is slow and there is no html as data is dynamic, it slides to the bottom, i.e., footer and then it has to be manually scrolled to the product DOM. I tried to disable the automatic scroll for the PDP click scenario using the below code: