Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
Using swfobject.addDomLoadEvent() to simplify the initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
gimite committed Dec 14, 2011
1 parent 4f7b9f8 commit 841b01d
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions web_socket.js
Expand Up @@ -370,20 +370,12 @@
};

if (!window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION) {
var init = function(){
// NOTE:
// This fires immediately if web_socket.js is dynamically loaded after
// the document is loaded.
swfobject.addDomLoadEvent(function() {
WebSocket.__initialize();
};
if (document.readyState == "complete") {
// Document is already loaded.
init();
} else if (window.addEventListener) {
// This fires earlier but is not supported by all browsers.
document.addEventListener("DOMContentLoaded", init, false);
// This is supported by all browsers.
window.addEventListener("load", init, false);
} else {
window.attachEvent("onload", init);
}
});
}

})();

0 comments on commit 841b01d

Please sign in to comment.