detecting exit-intent caused by back/forward, close tab/browser and url bar
i know that the beforeUnload event can be used to detect when the user is moving off the page.
I also know that events which nothing to do with the DOM such as back/forward, close tab/browser and url bar use cannot be detected directly which means the following psudocode is not possible
- $(window).on('beforeUnload' , function ( e ) {
- if( event.target = back/forward || close tab/browser || url bar ) {
-
- return "please dont leave";
- }
- });
Is there any way to achieve the desired result by process of illimination
If detect if the event was NOT on a DOM object?