Captue window.close() event

J

jimmy

Hi all,
I want to capture the event when the browser's close button is
clicked
in an html page.
I tried using the event.ClientX and event.ClientY property in the
body unload event, and this helps to recognise whether the close
button is clicked( also differentiates whethet refresh was clicked).
The problem arises whenever i try to close the window by resizing it
or by right clicking at the bottom of the page and then closing it.
Can anybody tell how to capture the window.close() event??
 
J

jimmy

How do you actually close a window by resizing it?
I meant after resizing it...
Why do you want to "capture" the close event? What exactly are you
trying to do? Can you provide explanations, description regarding your
webpage goals, requirements, purposes? What close event do you really
want to "capture": the webpage being unloaded or the window being closed?
In which way dealing with the closing of the window or unloading of a
webpage is actually contributing to the content for the users or
contributing to the experience of the users?
Problem is that whenver te user changes the data on the screen and
leaves it without saving the data, I prompt user to save the data by
calling a function on the body onunload event.

So in the body unload event i call a function which does the following
thing:-
****************************************************
if (event.clientY < 0 && event.clientX > 500)
{
//don't ask the user to save the data


}


***************************************************
Event here refers to the click and
event.clientY < 0 ensures that the button wasn't clicked in the
body and event.clientX >500 ensures that the user is not prompted to
save
when the refresh button is clicked, bcoz the page would unload in
that
event also.
I know that event.clientX >500 won't work when the screen size or the
browser's size is small...that is one of the problems i m facing
besides the user closing the window using Alt+F4 or by right clicking
at the bottom and then closing it..
 
T

terriblecow

I think there is a way to do it. Just open your gmail account and
compose a new message. If you navigate away from the page or close
the browser there is a popup to save changes.

I think this is excatly what jimmy was looking for. And quite frankly
I'm looking for the same thing. I'm going to be looking through the
google code to see if I can figure out how they interrupt/catch the
close event.

If anyone has any other comments they are quite welcome.

Thanks!
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top