Is there a way that you can redirect to the previously accessed route without actually going 'back' in the browser history? As in, going to the previous route but the 'forward' button on your browser will still be unclickable as you didn't physically go 'back' in the browser.
Asked
Active
Viewed 510 times
2 Answers
0
You can try to go to previous route:
window.history.back()
And then clear the forwarded pages:
history.pushState(null, document.title, location.href)
You may refer to this link. I guess there are multiple ways to clear forward button: HTML5 history disabling forward button

Imtiyaz Shaikh
- 425
- 3
- 7
0
You can just use the document
global of the browser and change the location imperatively:
document.location.href = "your-page-here.html"
If you are using react you wouldn't ever be changing the browser's location anyway so just use react-router or something similar to change the current route/Component

Travis James
- 1,879
- 9
- 22
-
Thanks for the answer. So I'm using nested react routes and was wondering how I can return to the previously accessed nested route each time I click a button. – deejay123 Sep 17 '19 at 17:27