0

This question is all about enabling browser back button after disabling it.

My requirement is to disable the browser back button for particular page on some condition. And I need to again enable it for other pages or for same page for other conditions. E.g. When user comes from page1 to page2, back button on page2 will be disables. Once user performs some specific opration on page2 than it will be enabled.

I have disabled browser back button by using bellow JavaScript code.

history.pushState(null, null, document.URL);

Now I have to enable it back for other pages (Even on same page after performing some specific operation).

There is so many stackoverflow questions and answers for disabling it. But I didn't find any questions for enabling it back.

Deepak Kumar
  • 1,246
  • 14
  • 38
  • 3
    That is highly unlikely you will be able to enable a disabled back button - I suggest you design the flow differently than something that needs to you break browser functionality. For example hide parts of the page – mplungjan Nov 22 '18 at 09:17
  • Possible duplicate of [Disable browser's back button](https://stackoverflow.com/questions/961188/disable-browsers-back-button) and [How to disable back button navigation on certain pages](https://stackoverflow.com/questions/3359941) and [disable browser back button](https://stackoverflow.com/questions/5673253) – adiga Nov 22 '18 at 09:24
  • 1
    Actually, User will be create record on page1, and after that it will go to page2. On page2 user need to save the record than only user can go to any other page of website. Before saving the record on page2 user should not go to any other page. – Deepak Kumar Nov 22 '18 at 09:25
  • This is way too dangerous idea in terms of controlling the very obvious behaviour of a system. What would be the user's intentions to go back to page 1 ? Either they want to edit record on page 1 or they want to abort this thing. Why dont you handle this in user's perspective. – Sahil Mahajan Mj Nov 22 '18 at 09:59

1 Answers1

0

That's a bad practice, you can create an execution flow with a form wizard

javimovi
  • 366
  • 2
  • 10
  • 1
    The functionality is like, user will perform some operation on page1 and on submit it will get updated in DB and it will redirect to page2 some some related operations. Until user completes validation on page2, User show not allowed to go back. – Deepak Kumar Nov 22 '18 at 09:28