I am wondering if it is possible to detect whether the user exits the Chrome browser?
EDIT - Sorry, I wasn\'t being very clear so I\'ll explain my situation. I am st
You can hook the OnBeforeUnload
event of the window
<script type="text/javascript">
$(window).bind('beforeunload', function() {
if (iWantTo) {
return "Don't leave me!";
}
});
</script>
Or create a JavaScript timer that pings your sever every XX seconds. When the pings stop, you can assume the user has closed the browser or navigated away.
http://ajaxpatterns.org/archive/Heartbeat.php
They have lots of good stuff in their documentation. onRemoved
of the window object would seem to do it.
http://code.google.com/chrome/extensions/windows.html#event-onRemoved
Or perhaps you mean tabs. In which case the onRemoved
for the tab object would do it.
http://code.google.com/chrome/extensions/tabs.html#event-onRemoved
API Index