Click here to Skip to main content
Click here to Skip to main content

Disabling browser's back button

, 6 Aug 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Disabling the browser's back button.


A web browser has back and forward buttons to navigate between webpages, whose URLs are stored in the browser's history.

Problem Statement

When you are using web forms and authenticated pages you don't want the end user to use back and
forward buttons of the web browser  to navigate as you will be providing all the navigation
required through your application's menu based on workflow.  

The most common problems an application designer should consider are as follows:

  1. Resubmission of web form data, which might create duplicate entries.
  2. Issues with workflow of the application.  
  3. Compromised application security.

Even though if you somehow tweak the web browser to disable the back and forward buttons, you are destroying the fundamental functionality of the web browser i.e. navigation. You might require back and forward buttons when you are browsing static pages. 

But technically disabling the browser's back button is not possible through webpage code, how ever
there is a workaround for it.


The following workaround should be added in the <head> section your  webpage/master page, where you don't want the user to be revisiting using a browser's back button:

<script language="javascript" type="text/javascript">

Compatibility verified in

  1. Internet Explorer 
  2. Google Chrome  
  3. Mozilla Firefox  
  4. Opera 


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


About the Author

Srinivas Kalabarigi
Software Developer (Senior)
India India

Around 8 years of software development experience and involved in analysis, design, development, testing and deployment of enterprise web applications for government, healthcare and banking domain with good exposure to object-oriented design, software architectures, design patterns, test-driven development and agile practices.

Educational Background
  • Post Graduation in Computer Science from Andhra University, India.
  • Graduation in Mathematics, Electronics and Computer Science from Andhra University, India.
  • Diploma in Software Technology from CMC Ltd., India.

Comments and Discussions

QuestionThxs for the nice and useful snipet :) PinmemberVendito24WEB7-May-14 0:36 
QuestionDisabling Browser's Back Button Pinmemberdgtheboss17-Nov-13 8:17 
SuggestionThis is not sufficient and generic way to handle browser back button PinmemberSanjay Gupta (Tech Archit)12-Sep-13 13:58 
SuggestionRe: This is not sufficient and generic way to handle browser back button Pinmember VICK8-Jan-14 19:00 
GeneralMy vote of 1 PinmemberHaBiX7-Aug-13 19:36 
QuestionMy dev side says yes, but my user side says no! Pinmemberryanoc3337-Aug-13 2:54 
GeneralMy vote of 2 PinprofessionalAlexCode6-Aug-13 20:38 
GeneralRe: My vote of 2 PinprofessionalSrinivas Kalabarigi6-Aug-13 20:52 
GeneralRe: My vote of 2 PinprofessionalAlexCode6-Aug-13 21:04 
GeneralMy vote of 2 Pinmemberdamian-piatkowski6-Aug-13 10:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 7 Aug 2013
Article Copyright 2013 by Srinivas Kalabarigi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid