I need to prevent the user from backward navigation in some parts of an app I am building. So far I am using this method:
ngOnInit() {
history.pushState(null, null, location.href);
window.onpopstate = function(event) {
history.go(1);
};
}
ngOnDestroy() {
window.onpopstate = function(event) {
history.go();
};
}
This is working great except on iOS chrome and safari. I've also tried:
history.replaceState(null, document.title, location.pathname);
in ngOnInit with not luck. Can someone enlighten my on how browsers on these mobile devices are using history and/or popstate differently than on windows/macOS versions of browsers?