I want to fire a function ( client side ) when the user is trying to leave the page only, by means if the user try to post back the page it shouldn't fire out, but only in condition that user is closing tab or closing window... at the time only the code will fire up.
I tried window.onbeforeunload
unfortunately it generates in all conditions (User navigating - refresh - Post back - closing tab - etc...) ... But i need an event to fire function only when user is closing page and it would be great if i can also figure out when the user is changing URL too.
I'm using ASP.Net attaching JavaScript code to it for maintenance purpose.