Using javascript, when the tab is closed the alert is shown to user to confirm leaving the page , but the problem is i want to detect which button "Leave this page" or "stay on this page" is clicked as i have to perform some function based on this.
<script>
window.onbeforeunload = function() {
return 'are you sure';
}
</script>