Introduction
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:
- Resubmission of web form data, which might create duplicate entries.
- Issues with workflow of the application.
- 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.
Workaround
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">
window.history.forward();
</script>
Compatibility verified in
- Internet Explorer
- Google Chrome
- Mozilla Firefox
- Opera