How to control the browser buttons using java script?

I need to disable the browser back button while cliking the submit button in html page to secure the process has not terminated.

Here is the code to disable the back button in browser, but it's working in onload event only. when i am trying to use this in onclick event it wont work.

<html xmlns="" >
<head runat="server">
<title>New event</title>
<SCRIPT type="text/javascript">
function noBack() { window.history.forward(); }
<BODY onload="noBack();"
onpageshow="if (event.persisted) noBack();" onunload="">
<a href='page2.html' >Page 2</a>

Can anyone know how to disable the browser back button while i am clicking submit button in html page


It won't work because on click, it will run before navigation--so it will go to the nonexistant "forward" page.

Use onbeforeunload

var submitFlag=false;
//set submitFlag to true on onclick of submit button
  return false;
 return "Are you sure you want to leave?"


This cannot force the user though. You can never force the user not to go back. Otherwise, this can lead to big security issues.

Need Your Help

Java Stanford NLP: Part of Speech labels?

java nlp stanford-nlp part-of-speech

The Stanford NLP, demo'd here, gives an output like this:

Set Comparability for Objects in ECMA6 JS

javascript set comparator equality ecmascript-6

I've been using a set to store and retrieve simple objects which represent coordinates.