I want to prevent browser back button to not go to previous page.
For this I tried below code:
<script type = "text/javascript" >
function preventBack() { window.history.forward(); }
setTimeout("preventBack()", 0);
window.onunload = function () { null };
</script>
but when I click on browser back button continuously 2-3 times at one go, it again redirects to previous page. So my above code fails.
I don't want user to go to previous page.
I tried this code as well:
<script>
$(document).ready(function () {
function disableBack() { window.history.forward() }
window.onload = disableBack();
window.onpageshow = function (evt) { if (evt.persisted) disableBack() }
});
</script>
but this code is removing the scroller from browser and I am unable to scroll the page.
Please reply some solution. I tried searching many articles but could not find any solution.