I have tried this, but the back page is showing for 1 or 2 secs and after that it comes back to the current page. I don’t want to go to Backpage even for 1 or 2 sec.
<script type="text/javascript">
function preventBack() { window.history.forward(); }
setTimeout("preventBack()", 0);
window.onunload = function () { null };
</script>
I have write this code in Asp.net .aspx file.
Is their any other way?
2
Answers
What you are wanting to do is client side logic. So asp.net vs node vs php doesn’t really enter into this.
You are on the correct track. I’d suggest adding a window.history.pushState({}, ”, window.location) to your initial code so the browser sees the first back button press as hitting the same page. Also check out window.onhashchange
I think this snippet will help you out: