让ie6也支持websocket采用flash封装实现(2)


var handlers = {
'connects':[],
'onClose':function(index,flag) {
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);
}
};
function 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 = '<object type="application/x-shockwave-flash" data="websocket4ie.swf" width=0 height=0>\
<param value="window">\
<param value="websocket4ie.swf">\
<param value="high">\
<param value="false">\
<param value="always">\
<param value="movieName=socket_'+this.index+'&handlers=handlers&server='+domain+'&port='+port+'&debug='+this.debug+'"></object>';
var div = document.createElement('div');
div.id = "flash_"+this.index;
div.innerHTML = html;
document.body.appendChild(div);
}
this.onClose = function() {
}
this.onConnect = function() {
}
this.onData = function(text) {
}
this.init();
}

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wddwsw.html