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

  •  08-29-2007, 2:45 PM

    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. }
View Complete Thread