Click here to Skip to main content
12,701,573 members (34,059 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked

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
Technical Lead
India India
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionThxs for the nice and useful snipet :) Pin
Vendito24WEB7-May-14 1:36
memberVendito24WEB7-May-14 1:36 
QuestionDisabling Browser's Back Button Pin
dgtheboss17-Nov-13 9:17
memberdgtheboss17-Nov-13 9:17 
SuggestionThis is not sufficient and generic way to handle browser back button Pin
Sanjay Gupta (Tech Archit)12-Sep-13 14:58
memberSanjay Gupta (Tech Archit)12-Sep-13 14:58 
SuggestionRe: This is not sufficient and generic way to handle browser back button Pin
VICK8-Jan-14 20:00
member VICK8-Jan-14 20:00 
GeneralMy vote of 1 Pin
HaBiX7-Aug-13 20:36
memberHaBiX7-Aug-13 20:36 
QuestionMy dev side says yes, but my user side says no! Pin
ryanoc3337-Aug-13 3:54
memberryanoc3337-Aug-13 3:54 
GeneralMy vote of 2 Pin
AlexCode6-Aug-13 21:38
professionalAlexCode6-Aug-13 21:38 
GeneralRe: My vote of 2 Pin
Srinivas Kalabarigi6-Aug-13 21:52
professionalSrinivas Kalabarigi6-Aug-13 21:52 
GeneralRe: My vote of 2 Pin
AlexCode6-Aug-13 22:04
professionalAlexCode6-Aug-13 22:04 
GeneralMy vote of 2 Pin
damian-piatkowski6-Aug-13 11:56
memberdamian-piatkowski6-Aug-13 11:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 7 Aug 2013
Article Copyright 2013 by Srinivas Kalabarigi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid