How can i know if the user click the right red close button in the browser and the close button of the tab
the idea is that i want when the user click the close red button or the close (X) of the tab a message appear to say are you sure you want to log out if he click yes he will be redirect to a logout page (i use php in this page) if not he will stay in the same page
i tried this code
window.onbeforeunload = function (e) {
e = e || window.event;
// For IE and Firefox prior to version 4
if (e) {
e.returnValue = 'Sure?';
}
// For Safari
return 'Sure?';
};
but it didn't give me the result i want when i click on the red close button the browser close and when i click on a link a message appear
can any one help to do this ?!