0

There are some way of detecting a close event from tab/browser without close when i click in other links in page or forms and valid for all browser, i tested "beforeunload" and other replies about this topic here and not working, i am testing in Firefox and Chrome This is not working :

window.onbeforeunload = function (event) {
    var message = 'Important: Please click on \'Save\' button to leave this page.';
    if (typeof event == 'undefined') {
        event = window.event;
    }
    if (event) {
        event.returnValue = message;
    }
    return message;
};

Same when i close the tab or the browser is doing nothing; but yes when i click a link

Felipe Mora
  • 42
  • 1
  • 11
  • 1
    Possible duplicate of [Trying to detect browser close event](https://stackoverflow.com/questions/20853142/trying-to-detect-browser-close-event) – Huangism Apr 23 '18 at 14:44
  • 1
    Note: a window/tab close event cannot be prevented "silently" the same way than other events. At maximum, you can show an alert asking the user if he wants to leave or not – Kaddath Apr 23 '18 at 14:47
  • Does this answer your question? [How to Detect Browser Window /Tab Close Event?](https://stackoverflow.com/questions/21227383/how-to-detect-browser-window-tab-close-event) – Mišo Nov 26 '19 at 14:11

0 Answers0