0

I am trying to trigger event when user hit the back button on my web page and then show an alert window. I've tried all the possible solutions, but each works only after user interacts with my web page, for example: .onbeforeunload, or

if (window.history && window.history.pushState) {
    window.history.pushState('forward', null, './#');

    $(window).on('popstate', function () {
      alert('Are you sure?');
      window.history.pushState('forward', null, './#');
    });
}

I want to ask you, if is it possible, to show alert window without any previous interaction, especially on mobile browsers?

Fidas
  • 41
  • 2
  • 7
  • https://stackoverflow.com/questions/25806608/how-to-detect-browser-back-button-event-cross-browser Reference same issue – Duy Tran Feb 25 '20 at 17:56
  • Please, are you able to more describe that answer? Because I am lost in that solution – Fidas Feb 25 '20 at 18:02

0 Answers0