I know that (using Jquery) you cant detect when your page is about to unload for any reason using the beforeUnload event
eg
$(window).on('beforeUnload' , function ( e ) {
return "please dont leave";
});
Is it possible to detect if this was caused by something outside of your page such as closing the tab/window or using the back/forward buttons.
If use of such things cannot be detected normally is it possible to determine with certainty that beforeUnload was NOT triggered by any event on any DOM element?