我的WebSocket在Opera / Midori中不起作用

时间:2015-02-20 01:11:37

标签: javascript websocket

每个人我都在创造一个"对象"管理有关我的套接字连接的所有信息,但我有一些关于浏览器兼容性的问题

$(document).ready(function(){
 socket.connect();

 socket.connection.onopen = function(){
 console.log('Connected '+ socket.connection.readyState);
 //Show 1 for every browser
};

socket.connection.onmessage = function(event){
   console.log('Some message '+event.data);
  //Firefox / Chrome Fine
  //Midori/Opera doesnt show this message (console)
 };
});

var socket ={

dataConnection: {
   url:"myURL",
  param:"myParam"
},
connection: "",
connect: function(){
  try{
    this.connection = new WebSocket(this.dataConnection.url+"/"+this.dataConnection.param);
  }catch(error){
    console.log('Something wrong ' + error.message);
  }
}

};

我不明白Wy工作得很好(FF和Chrome),你能提出建议吗?

0 个答案:

没有答案