Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/04/2013, 08:50
SeaPirates
 
Fecha de Ingreso: enero-2009
Ubicación: España
Mensajes: 786
Antigüedad: 15 años, 3 meses
Puntos: 9
HTML5 WebSockets problemas de compatibilidad

Hola, el código que tengo me funciona perfectamente en chrome, pero en firefox no funciona y no sé por qué motivo. ¿Alguna solución?

Código Javascript:
Ver original
  1. // let's invite Firefox to the party.
  2. if (window.MozWebSocket) {
  3.   window.WebSocket = window.MozWebSocket;
  4. }
  5.  
  6.     var chat = document.getElementById('chat');
  7.     var form = chat.form;
  8.     var conn = new WebSocket('ws://node.remysharp.com:8001');    
  9.    
  10.     conn.onopen = function () {
  11.       //Conexion abierta
  12.     };
  13.  
  14.     conn.onmessage = function (event) {
  15.  
  16.       var message = event.data;
  17.       if (!(/^\d+$/).test(message)) {
  18.         alert("Mensaje recibido" + message);
  19.       }
  20.     };
  21.    
  22.     conn.onclose = function (event) {
  23.      //Conexión cerrada
  24.     };
  25.  
  26.     addEvent(form, 'submit', function (event) {
  27.         event.preventDefault();
  28.         conn.send(JSON.stringify(chat.value));
  29.  
  30.   });