Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12201

disable browser back button in angular 8

$
0
0

I want to disable browser back button on specific condition, after implementing several snippetslike History,popstate etc

scenario 1: its making the code not able to use back button for anything disregarding the condition.

scenario 2: once you click back button twice its going back to browsers home page not able to know whats happening

window.addEventListener("popstate", (e) => {  const es = 'D'  if (es == "D") {    e.preventDefault();    var currentLocation = window.location.pathname;    window.history.pushState(      {},"",      `${currentLocation}/index/watchlist/home`    );  } else {

Need: Need to disable the back button conditionally but if the condition is false it should work


Viewing all articles
Browse latest Browse all 12201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>