I have a website in ASP VB.NET and there's a page that goes back to the previous one when clicked, we did this with JavaScript:
window.history.back();
But this gets you to the previous page on the state it had when going to the current page, we need it to reload, how can you do this?
You can't use window.history
to achieve your desired behaviour because this is not how it works. window.history
preserves the session history of the pages visited (as stated here - it essentially mimics your browsers back/forward buttons.
As stated in the document:
There is no way to clear the session history or to disable the back/forward navigation from unprivileged code. The closest available solution is the
location.replace()
method, which replaces the current item of the session history with the provided URL.
So your best bet to make this work would be to use location.replace()
. You can get the previous URL of where you came from using document.referrer
.
location.replace(document.referrer);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With