views:

636

answers:

5

When a web application running and on close the browser window then which event raise?

+1  A: 

onunload is the event raised when closing the browser window.

How ever this event isn't fired only when closing the browser, that's just one case.

Brian Gianforcaro
you also can't depend on it 100% of the time. If the browser crashes then it won't be sent.
tloach
@tloach: if the browser crashes your options are limited
orip
A: 

The web browser doesn't send any notification to the web server when the user closer the window.

Tim
A: 

You may also be interested in onbeforeunload.

Armandas
+1  A: 

See existing topic:

http://stackoverflow.com/questions/299679/java-servlet-how-to-detect-browser-closing

Diodeus
I was about to point to that... :-)
PhiLho
A: 

See my answer at the thread pointed by Diodeus: basically, you cannot... Lot of browsers just no longer fire onbeforeunload and/or onunload. And even when they do, it is hard to distinguish between page reload, page jump and browser/window/tab closing.

PhiLho