How can i know when user clicks X button of the browser ?

A

Asit

How can i know when user clicks X button of the browser ?
I have to write some code when user clicks X button of browser. What is the
event for capturing this event ?

Help needed ASAP.

Asit
 
M

Michael Winter

How can i know when user clicks X button of the browser ?

The unload event fires when the document unloads, but a document can
unload for many things not just closing. Furthermore, some browsers don't
fire the unload event during closing, which makes it an even more
unreliable approach.
I have to write some code when user clicks X button of browser. What is
the event for capturing this event ?

If the user is closing their browser, it is generally too late for you to
be doing anything. What are you trying to accomplish? There might be an
alternate way.

Mike
 
T

Thomas 'PointedEars' Lahn

Asit said:
How can i know when user clicks X button of the browser ?

You cannot.
I have to write some code when user clicks X button of browser.

You don't have to.
What is the event for capturing this event ?

There is no standard compliant one that works cross-browser.
Help needed ASAP.

Refactor your server-side application, if you use any; do
not nag your users, if you do not. The latter is illegal.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top