0

I made a page with the same url all the time. I show my div by hiding and showing components, but no route. So, now I need the user can go back page using the back arrow of the explorer. Is there any possibility?

  • Take a look at the [history API](https://developer.mozilla.org/en-US/docs/Web/API/History_API). This is what react router uses internally to listen for back button events – mousetail Jul 27 '22 at 13:59

1 Answers1

1

The back button of the browser change the window history : https://developer.mozilla.org/fr/docs/Web/API/Window/history

So i don't think you can link the browser back btn to a javascript variable and prevent his effect on history

You can find on the net solution where people force history.forward() when back btn is pressed, you can change your variable here. But it's a bit dirty

How can I stop the browser back button using JavaScript?

H-DC
  • 92
  • 2