1

Would like to perform an action when the user is about to close the browser tab not when the user clicks the close button. How can it be done in javascript?

Don't want to use unload or beforeunload since it is triggered when the user clicks on close button or when the user navigates to another page.

aham
  • 137
  • 11
  • 1
    so far what you have tried – Arun Kumaresh Feb 24 '17 at 06:28
  • I think you need to work with native code to achieve that, different for Chrome, IE, or Firefox – buræquete Feb 24 '17 at 06:28
  • 1
    Check this link http://stackoverflow.com/questions/29808046/how-to-detect-the-event-when-the-mouse-pointer-is-over-the-close-button-of-the-b – Jhay Feb 24 '17 at 06:44
  • Only a limited set of events and actions are exposed by a browser. This I don't think that will be exposed. Check here:https://developer.mozilla.org/en-US/docs/Web/API/Window – Gayan Dasanayake Feb 24 '17 at 06:52
  • @Arun Kumaresh so far I have tried to get the result using pageY and clientY. But the values are not going beyond 0 so couldnt obtain the required result. – aham Feb 24 '17 at 07:03
  • Also tried mouseleave but the action gets triggerred even when the cursor is moved away from the browser window horizontally also. Want to trigger the action only when the cursor is moved towards the top of browser window towards close button – aham Feb 24 '17 at 07:05

0 Answers0