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="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>New event</title>
</head>
<SCRIPT type="text/javascript">
window.history.forward();
function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"
onpageshow="if (event.persisted) noBack();" onunload="">
<a href='page2.html' >Page 2</a>
</body>
</html>
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
onbeforeunloadThis cannot force the user though. You can never force the user not to go back. Otherwise, this can lead to big security issues.