views:

37

answers:

1

I have a Web Application and I want to get a confirmation from users when they are closing the application no matter what.

I mean I'm looking for a way to display a message touser whenever user try to close the application.


Update : I want to use my dialog box not browsers dialogbox. r at least a dialogbox which only shows my message no extra message.

+5  A: 

No need for jQuery here, just hook up the window beforeunload event

Demo

window.onbeforeunload = function() {
   return "Are you sure?";
}
redsquare
@redsquare - I used it before and whenever I refresh the window an error appeared and tell me method cannot found!!!!! where to use it?
Nasser Hadjloo
check my demo, link above
redsquare
@redsquare - Actually the dialogbox which is appeared is not suitable for me. I want to show Just my text not Browser text too. I'm waiting for your answer. Thank you in Advance.
Nasser Hadjloo
Apologies for not knowing what your question really was! You cant just change the context of a question, the answer suits your question.
redsquare
you cannot change the dialog because it is how browsers implement the event. There is no way to do what your asking in your comment
redsquare