How to disable and enable browser back button












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.










share|improve this question




















  • 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 9:17











  • Possible duplicate of Disable browser's back button and How to disable back button navigation on certain pages and disable browser back button

    – adiga
    Nov 22 '18 at 9: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.

    – DK Ansh
    Nov 22 '18 at 9: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 9:59
















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.










share|improve this question




















  • 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 9:17











  • Possible duplicate of Disable browser's back button and How to disable back button navigation on certain pages and disable browser back button

    – adiga
    Nov 22 '18 at 9: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.

    – DK Ansh
    Nov 22 '18 at 9: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 9:59














0












0








0


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.










share|improve this question
















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.







javascript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 9:33







DK Ansh

















asked Nov 22 '18 at 9:14









DK AnshDK Ansh

209111




209111








  • 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 9:17











  • Possible duplicate of Disable browser's back button and How to disable back button navigation on certain pages and disable browser back button

    – adiga
    Nov 22 '18 at 9: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.

    – DK Ansh
    Nov 22 '18 at 9: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 9:59














  • 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 9:17











  • Possible duplicate of Disable browser's back button and How to disable back button navigation on certain pages and disable browser back button

    – adiga
    Nov 22 '18 at 9: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.

    – DK Ansh
    Nov 22 '18 at 9: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 9:59








3




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 9:17





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 9:17













Possible duplicate of Disable browser's back button and How to disable back button navigation on certain pages and disable browser back button

– adiga
Nov 22 '18 at 9:24







Possible duplicate of Disable browser's back button and How to disable back button navigation on certain pages and disable browser back button

– adiga
Nov 22 '18 at 9:24






1




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.

– DK Ansh
Nov 22 '18 at 9:25





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.

– DK Ansh
Nov 22 '18 at 9: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 9:59





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 9:59












1 Answer
1






active

oldest

votes


















0














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






share|improve this answer



















  • 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.

    – DK Ansh
    Nov 22 '18 at 9:28











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427407%2fhow-to-disable-and-enable-browser-back-button%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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






share|improve this answer



















  • 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.

    – DK Ansh
    Nov 22 '18 at 9:28
















0














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






share|improve this answer



















  • 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.

    – DK Ansh
    Nov 22 '18 at 9:28














0












0








0







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






share|improve this answer













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







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 9:24









javimovijavimovi

318110




318110








  • 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.

    – DK Ansh
    Nov 22 '18 at 9:28














  • 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.

    – DK Ansh
    Nov 22 '18 at 9:28








1




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.

– DK Ansh
Nov 22 '18 at 9:28





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.

– DK Ansh
Nov 22 '18 at 9:28


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427407%2fhow-to-disable-and-enable-browser-back-button%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin