And the mooish way:

window.addEvent('beforeunload', function(event){
      event.returnValue = "Any string value here forces a dialog box
to appear before closing the window.";
});


2010/5/14 André Fiedler <[email protected]>

> It is stopable. I have used it, but you HAVE to show a user dialog:
>
>
> function closeIt()
> {
>      return "Any string value here forces a dialog box to appear before 
> closing the window.";
> }
> window.onbeforeunload = closeIt;
>
>
>
> 2010/5/14 Aaron Newton <[email protected]>
>
> I'm pretty sure that that event is unstoppable. Otherwise you could prevent
>> someone from ever leaving the page.
>>
>> On Fri, May 14, 2010 at 1:58 AM, Sitthykun LY <[email protected]>wrote:
>>
>>> cool,
>>>
>>> Please help me to work with beforeunload event
>>>
>>> var testClass = new Class({
>>>      initialize: function() {
>>>         this.onLoad();
>>>      },
>>>
>>>     onLoad: function() {
>>>        this.closeForm();
>>>     },
>>>
>>>     closeForm: function() {
>>>          window.addEvent('beforeunload', function(event){
>>>               event.stop(); /// it does not work
>>>               this.showMsg();
>>>          }.bind(this));
>>>   },
>>>
>>>   showMsg: function() {
>>>       .....
>>>  }
>>>
>>> });
>>>
>>>
>>> //---------------------------------
>>>
>>> window.addEvent('beforeunload', function(event){
>>>              * event.stop(); /// it does not work*
>>>               this.showMsg();
>>>          }.bind(this));
>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Sitthykun LY
>>>
>>
>>
>

Reply via email to