Introduction
Suppose in our application we have two web-pages namely first.aspx and second.aspx and let us imagine a situation that someone is redirecting to second.aspx from first.aspx and our requirement is that if we click on the backward button of the browser then this will not allow us to get back to first.aspx page.
To achieve this we need to put the following piece of code in the head section of first.aspx.
- <script type = "text/javascript" >
- function preventBack() { window.history.forward(); }
- setTimeout("preventBack()", 0);
- window.onunload = function () { null };
- </script>
Now, run your application and check it out..

Dharmendra DasPosted Feb 16, 2024, 4:53 AM
This is copied from ASPSnippets.com. Here is the link https://www.aspsnippets.com/Articles/88/Disable-Browser-Back-Button-Functionality-using-JavaScript/
Dhilipan NPosted Aug 25, 2022, 5:58 AM
Can we disable or stop the click event to the back button?
Samvedna YadavPosted Mar 30, 2022, 9:45 AM
It is working on edge and IE but ot working on chrome