2

One of my website there are multiple users can logged. so when any user directly close the browser current tab at that time we need to just prompt to pop up with specific message.

Right now i will used that code in javascript:

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;
    }
    console.log(event);
    return message;
}; 

but, it is not convenient for me.

The problem on above code that gives me every time pop up if page are refresh/reload but i want when close current tab with prompt.

Please help me.

piyush
  • 554
  • 5
  • 14
  • This problem has already been discussed in the following topic: http://stackoverflow.com/questions/3888902/javascript-detect-browser-close-tab-close-browser – mario.van.zadel Jul 31 '15 at 10:38
  • yes i have already seen that link but its not suitable for my scenario. – piyush Jul 31 '15 at 10:49

0 Answers0