I need to know if its possible to catch a user closing the browser window. I have tried using <body onbeforeunload="run_closeScripts()">
which works fine, but this is triggered on every postback! So its not much use if the user hits the refresh button or goes to another page.
Is there a reliable way to detect if its a full browser close rather than a postback?
<body onbeforeunload="run_closeScripts()">
<script type="text/javascript">
function run_closeScripts() {
//check if the browser is closing and not a postback
window.alert("Your checkout will be removed!");
window.location.replace("Exit.aspx");
}