I want to display a message when the user clicks on browser back button. For that, I have used below lines of code and its working fine in IE and Firefox browser.In chrome the below code is not working until I click on anywhere on window. Without clicking anywhere on window then if I click on the back button then it is going back. Anyone solution will help.
history.pushState(null, null, location.href);
window.onpopstate = function () {
ShowAlert('Back button functionality is disabled.', 'Error', 20);
history.go(1);
};