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:
- function window_onunload(){
- alert(1);
- Disconnect();
- }
- window.onunload=window_onunload;
- if(window.attachEvent)
- {
- window.attachEvent("onunload",window_onunload);
- }
- else
- {
- if(window.addEventListener)
- {
- window.addEventListener("unload",window_onunload,false);
- }
- else
- {
- window.onunload = window_onunload;
- }
- }