Click here to Skip to main content
14,980,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I want to disable browser back button (not only back button functionality). Not allowing user to click back button, it should be in disable mode.

Help me.


What I have tried:

I tried below code, worked for functionality but it allows user for clicking back button.

Updated 29-Nov-17 3:05am

Are people still asking this question?

Things you shouldn't spend time doing | The ASP.NET Forums[^]
Suvendu Shekhar Giri 29-Nov-17 9:56am
my 5!
You can't disable the back button from your web page.
Ramana RK 29-Nov-17 9:10am
Tnq Dave, But can you explain or guide me why can't we disable a back button of browser in my application webpage?
F-ES Sitecore 29-Nov-17 9:21am
The browser back button isn't a web standard, it is a convenience provided by your browser so they all implement it in their own way and there is no standard that allows your code to interact with browser features. Your code interacts with HTML, not the container the HTML is in. Let's say you *could* disable the back button....some browsers let you use alt-left, are you going to disable alt-left too? Maybe there is a browser out there somewhere you don't know about that let's you go back using do you know that such a browser exists and that you need to add that combo to your list of blocked commands? Let's say one browser uses ctrl-f4 to go back, and if you disable that in one browser you stop another browser being able to close the tab.

You can only control things that are defined via standards, each browser is its own implementation so there is no "container api" that lets you access browser features.

Now let's say you are trying to disable the back button for security reasons...what stops me writing my own browser that ignores any attempt to disable the back button?

You are thinking about your problem from the wrong angle, read the link I posted. You *can't* disable the back button, you have to accept that. So instead explain *why* you want to disable it and someone might have a solution.
Suvendu Shekhar Giri 29-Nov-17 9:56am
This is the perfect answer!
My virtual 5!
Dave Kreskowiak 29-Nov-17 10:30am
Because it's a massive security risk. Think about it. Would you let a potentially hostile web page manipulate the browser it's running in?

That's why web pages do not have any control over the browser.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900