2

I want user can not click out side the confirm pop-up. How to do it? Pop-up is happened when I click back button(browser)

if (window.history && history.pushState) {
  addEventListener('load', function () {
    history.pushState(null, null, null);
    addEventListener('popstate', function () {
      var stayOnPage = confirm("Are you sure? Mission will be failed");
      if (!stayOnPage) {
        history.pushState(null, null, null);
      } else {
        window.location = 'google.com';
      }
    });
  });
}
Ben Thomas
  • 3,180
  • 2
  • 20
  • 38

0 Answers0