The browser's Back button can redirect the user to the page previously viewed before the current page. If you want to prevent users from returning to the previous page of your web application, the browser's Back button must be disabled. Reverse browser navigation can be disabled using JavaScript. Use the history.pushState()
event and the onpopstate
property of WindowEventHandlers to stop backward navigation in browsers.
The snippet The code following disables the feedback browser button with JavaScript.
window.history.pushState(null, null, window.location.href);
window.onpopstate = function () {
window.history.go(1);
};
Read Also : How can managers foster a culture of open communication and transparency within their teams?
Answered 4 months ago
Matti Karttunen
The browser's Back button can redirect the user to the page previously viewed before the current page. If you want to prevent users from returning to the previous page of your web application, the browser's Back button must be disabled. Reverse browser navigation can be disabled using JavaScript. Use the
history.pushState()
event and theonpopstate
property of WindowEventHandlers to stop backward navigation in browsers.The snippet The code following disables the feedback browser button with JavaScript.