Hi,
i want to detect browser close event and show alert message.
Situation when i want to show message is only exit/close browser tab not on refresh or click link.

Thanks

  1. Google
  2. Leads to StackOverflow
  3. You've got your answer! Which is something like:

-----

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;
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.