2

I want to trigger my bootstrap modal when user tries to close the browser. I am trying to do it with below code but doesn't seem to be working.

window.onbeforeunload = function(e){
    $('#myModal').modal('show');
}

If it is not possible then how can I trigger it on closing or clicking the back browser button? Any help would be appreciated.

Kartikeya Khosla
  • 18,743
  • 8
  • 43
  • 69
TechieViking
  • 126
  • 1
  • 10

1 Answers1

0

According to this page https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload You can't display modal instead prompt while reloading the page.