Try the onbeforeunload
event: It is fired just before the page is unloaded. It also allows you to ask back if the user really wants to leave. See the demo onbeforeunload Demo.
Alternatively, you can send out an Ajax request when he leaves.
More Related Contents:
- “Uncaught SyntaxError: Unexpected token , ” when create my object javascript
- What is the difference between null and undefined in JavaScript?
- Get the last item in an array
- How can I check whether Google Maps is fully loaded?
- Prevent a webpage from navigating away using JavaScript
- How do I POST a x-www-form-urlencoded request using Fetch?
- Call a function after previous function is complete
- Download pdf file using jquery ajax
- Force a browser to save file as after clicking link [duplicate]
- Convert UNIX timestamp to date time (javascript)
- How to pass in a react component into another react component to transclude the first component’s content?
- Where is my implementation of rot13 in JavaScript going wrong?
- JavaScript DOMParser access innerHTML and other properties
- javascript print without print dialog box
- Regex and ISO8601 formatted DateTime [duplicate]
- RegEx – Get All Characters After Last Slash in URL
- How do I extract even elements of an Array?
- How does (A == B == C) comparison work in JavaScript?
- Example of a circular reference in Javascript?
- Cancel single image request in html5 browsers
- How to iterate through property names of Javascript object?
- how to get the base url in javascript
- Express: Setting content-type based on path/file?
- HTML5 input required, scroll to input with fixed navbar on submit
- Selecting elements without jQuery
- Function not calling within an onclick event
- Set cookie on multiple domains with PHP or JavaScript
- In JavaScript, how can I replace text in an HTML page without affecting the tags?
- Get Element StyleSheet Style in JavaScript
- Is there a way to catch an attempt to access a non existant property or method?