I need to prevent click of the browser back button. When user clicks on browser back button from desktop or mobile we need to stay on same page. I tried different solutions from internet (some of them are working for Firefox). One of the code that is working on Firefox only:
window.history.pushState(null, "", window.location.href);
window.onpopstate = function () {
window.history.pushState(null, "", window.location.href);
};
On chrome or safari or edge browser when we do external click on page then only above code will work and user will be prevented to click on the back button. Please help me for this issue