On 19.01.2007, at 12:29, Klaus Hartl wrote: > Unai Martinez schrieb: >> How can i detect browser close event? >> >> I've tried something like:
> > I don't think that you can - or if my knowledge here is limited > that it > is a good idea to - stop the user from closing the window... He could have a try at the proprietary (originally MS-only, but now Gecko also implements it) onbeforeunload Event. That event allows to return a string which is shown to the user who can then choose to either abort the page switch/window close or continue. Due to it's unusual behavior (you have to return the text for Mozilla and set it as "returnValue" property on the window.event object for IE) there might be problems getting this to work with the jQuery event system, though - I haven't tried this yet. Anyway, that event _can_ be useful if you do not rely on it. It's for example rather helpful for warning users if they entered data into a form without saving (though, of course, AJAX auto-submits give the developer a better amount of control for such issues) -- Markus Peter - SPiN AG http://www.spin-ag.de/ [EMAIL PROTECTED] _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/