複製🎜>複製🎜>代碼
代碼如下:
var handlers = {
'connects':[],
'onClose':function(index,flagect) {
this.connects[index.replace("socket_","")].onClose();
},
'onConnect':function(index) {
this.connects[index.replace("socket_","")].onConnect();
},
'onData':function(index,text) {
this.connects[index.replace("socket_","")].onData(text);
},
'debug':function(index,str) {
console.log(str);
}
};
函數socket4ie() {
this.debug = 0;
this.init = function() {
this.index = handlers.connects.length;
handlers.connects.push(this);
}
this.connect = function(domain,port) {
this.createFlash(domain,port);
}
this.createFlash = function(domain,port) {
var html = '
' ;
var div = document.createElement('div');
div.id = "flash_" this.index;
div.innerHTML = html;
document.body.appendChild(div);
}
this.onClose = function() {
}
this.onConnect = function() {
}