-1

I tried doing it this way but it takes interaction with the screen for it to work, is there any way to make it work without interaction

history.pushState(null, document.title, location.href);
    history.back();
    history.forward();
    window.onpopstate = function () {
        history.go(1);
    };
Tungnt
  • 1
  • I think this is duplicate of [this](https://stackoverflow.com/questions/25806608/how-to-detect-browser-back-button-event-cross-browser) – Zhivko Nikolov Nov 22 '22 at 10:00
  • I don't think it's possible and I also think that it shouldn't be possible because it's horrible UX – tstrmn Nov 22 '22 at 10:00

1 Answers1

0

do you mean disable back button of a browser?

window.history.pushState(null, null, window.location.href);

window.onpopstate = function () { window.history.go(1); };

Peter Lam
  • 1
  • 4