3 ms·
This site hijacks the back button and I really hate that. Shouldn't there be some way for the browser to prevent that?
by sneed_chucker 2y ago
This site hijacks the back button and I really hate that.
Shouldn't there be some way for the browser to prevent that?
- breck 2y agoCan you explain what you mean? It's definitely not intentional, and should be easy to fix. The source code is 100% open source and pull requests are encouraged: https://github.com/breck7/pldb https://github.com/breck7/pldb
- Masterjun 2y agoLooking at the code, the issue is most likely a modification of window.location or its child properties. Any modification of these things will cause the browser to navigate to the new page, adding a new browser history entry. Then, whenever a user tries to go back, it will rerun the code that causes the browser to nagivate to the new page, so you end up on the same page you started on. It feels like the back button was hijacked. To fix this, usually the two ways to change the URL without changing the browser history are either using window.location.replace() which will navigate there as well, or using window.history.replaceState() which will only change the URL without naviating there.