I have to show a confirmation dialog to user when he tries to close the window.
The user could navigate to others pages, the message should appears only in closing windows (or tab).
I tried this but it's alerts in navigation too:
window.onbeforeunload = confirmExit;
return " Are you sure you want to exit this page?";
How can I alert the user only when he tries to close the window (or tab)?
Thanks in advance!