window.addEventListener('popstate', function(event) {
alert("you are not able to push back button");
});
I have create the web application using polymer 2.0 but I have to click on the back button to the browser is logout I have to show the alert if the user is click on the back button of the browser I have tried window.addEventListener but still got error.
I've not been able to stop the browser's back button, but I've managed to get around it. In my app, I want to warn the user that they will log out by backing up to the first page, and give them a chance to leave or stay put. Using the
polymer-2-starter-kitas my starting point, and tracking aconnectedproperty, I got this working:So if the user is connected, and navigates to the initial page, I can force them to stay on the page where they were with
window.history.forward().