I have a query regarding my application. Whenever user closes browser window accidentally I\'d want to do some clean up operations before that. I have used onunload event bu
window.onbeforeunload = function() { return 'You have unsaved changes!'; }
See the MSDN article on onbeforeunload
Also there is a similar question in SO