470,581 Members | 2,427 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,581 developers. It's quick & easy.

window close event

Hello all,

I want to trap the window.close() event when the user clicks on the
close button of the browser using javascript.
Can anyone shed light on this problem ?

Thanks in advance.

regards
casper
Jul 20 '05 #1
1 3516
ca*********@rediffmail.com (abhay) writes:
I want to trap the window.close() event when the user clicks on the
close button of the browser using javascript.


Can't be done consistently across browsers.
In IE, you can use the proprietary "onbeforeunload" handler to
do something before the window is closed. You can even request
that the window is not closed, by returning a string. That string
is shown to the user, who can then decide whether to close the
window or not.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Darren | last post: by
2 posts views Thread by RJN | last post: by
5 posts views Thread by lindanr | last post: by
5 posts views Thread by jimmy | last post: by
15 posts views Thread by Mahernoz | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.