When close chat window, window.onunload() code was excuted twice

Last post 08-30-2007, 3:37 PM by JaneL. 4 replies.
Sort Posts: Previous Next
  •  08-29-2007, 2:45 PM 33056

    When close chat window, window.onunload() code was excuted twice

    I integrated CuteChat with our software. But when I close the chat window by click the X button at the right top, window.onunload code was excuted twice. If I close the chat window by click the logout button, the onunload() code was execute once normally. How can I make it run normally even I click the x button? thanks in advance, appreciate. 
    the code like:
          
    1. function window_onunload(){
    2. alert(1);
    3. Disconnect();
    4. }
    5. window.onunload=window_onunload;
    6. if(window.attachEvent)
    7. {
    8. window.attachEvent("onunload",window_onunload);
    9. }
    10. else
    11. {
    12. if(window.addEventListener)
    13. {
    14. window.addEventListener("unload",window_onunload,false);
    15. }
    16. else
    17. {
    18. window.onunload = window_onunload;
    19. }
    20. }
  •  08-29-2007, 3:06 PM 33057 in reply to 33056

    Re: When close chat window, window.onunload() code was excuted twice

    Please remove the following code:
     
    //window.onunload=window_onunload;
     
    I will let developer aware this issue and fix it soon.
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-29-2007, 3:37 PM 33062 in reply to 33057

    Re: When close chat window, window.onunload() code was excuted twice

    Thanks for your quick reply, Adam.

    I tried to remove either this line or remove the window.attach.. lines, or even just put the code in <body onunload="window_onunload()">. In these case, the code will only triggered once (one alert shows), but looks like the chat window  is not close properly:  The person's record still in CuteChatClient table; And if I tried to open another chat window, that will freeze all my application running, I have kill it from windows task manager .
     
    Any advise is very welcome, thanks very much.
  •  08-30-2007, 2:00 PM 33104 in reply to 33062

    Re: When close chat window, window.onunload() code was excuted twice

    JaneL ,
     
    I just discussed it with the developer.
     
    Please don't remove the above code.
     
    The correct method should be:
     
    window.onunload=window_onunload;
     
    function window_onunload(){ 
       if(window.__unloadcalled)return;
       window.__unloadcalled=true;
       Disconnect();
    }
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-30-2007, 3:37 PM 33118 in reply to 33104

    Re: When close chat window, window.onunload() code was excuted twice

     
    Adam,
     
    Thanks. I tried your suggestion, but I got the similiar result: the record of user (dbo.cutechatclient) still here after logged out from X button. And also after I tried to log in again 3rd time, everything will be freezed, it shows: msxml3:timeout error. Any advise? Thanks again for your effort.
     
    JaneL
View as RSS news feed in XML