tags:

views:

343

answers:

3

Hi Guys,

Is there a way to trap the browser closing event from javacript. I don want to do this in Page Unload event or anything... it must be handled on clicking the browser close button..

is it possible??

Cheers

Ramesh Vel

+4  A: 

No. You only have onbeforeunload event, available as raw javascript (jquery doesn't include this event).

If you want to try it, try to post here an answer and, without pressing "post your answer" try to close the browser window.

This is the closest way to access the "close window" event.

Ionut Staicu
A: 

Not really. Page unload event is all you have. And even that not always. It would provide the ability to interfere with user's wishes pretty bad.

EFraim
A: 

You can't really do it but my question to you is for what reason would you want to capture that? Maybe there's an alternate way to solving your problem.

Keith
Am workin in a project where i have to maintain the last accessed state of page internally in client side, and i need to persist this in db on the app session ends.. And i dont want to do it everytime my page unloads?? it ll be time consuming and unnesessary..
Ramesh Vel