Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  92] [ 3]  / answers: 1 / hits: 39363  / 13 Years ago, tue, may 10, 2011, 12:00:00

I want to disable the back buttons in the browser using JavaScript. Can any one help me how to do that?


More From » html

 Answers
4

Read here for several options to disable the back button.


BUT: The question makes me feel like you're trying to solve the wrong problem.


The back button is something that the user expects to work. If you disable it, you would break the browser (from the user perspective): Something that works everywhere else doesn't work on your page. Users would hate your page and try to avoid it. If they can't avoid the page, they would hate it even more.


So what are your options:



  1. You can get events when the user uses the button. GWT, for example, saves the internal state of the application in virtual history events. So the user can use the back button like Undo in a real application.



  2. Avoid creating history events for your page. Make sure the URL in the title bar never changes. Save all changes on your server. For the user, the page/application will feel like one page. When he returns next time, restore the last state from the database on your server.


    This way, the user can use the back button to leave your page as he is used to but he still won't loose any work.



  3. A mix of the two. For example stack overflow allows you to move between the pages using links and the back button. If you start to edit something on a page, you get a warning when you click on the back button.




[#92312] Sunday, May 8, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kayden

Total Points: 546
Total Questions: 102
Total Answers: 95

Location: Virgin Islands (U.S.)
Member since Fri, Mar 4, 2022
2 Years ago
;