Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/10/2012, 10:49
Avatar de Heiroon
Heiroon
 
Fecha de Ingreso: junio-2010
Ubicación: Caracas, Venezuela - Por ahora...
Mensajes: 495
Antigüedad: 13 años, 11 meses
Puntos: 63
Exclamación Uso correcto de attachEvent

Buenas, tengo entendido que este método, solamente funciona en Explorer y Opera. Pero lo quiero usar para reemplazar el método addEventListener.

Código Javascript:
Ver original
  1. var xmlhttp = new XMLHttpRequest();
  2.         url = "ajax/moveMap.php?" + params;
  3.         xmlhttp.onreadystatechange = function ()
  4.         {
  5.             if(xmlhttp.readyState != 4)
  6.             {
  7.                 document.getElementById('loadingMap').style.visibility = "visible";
  8.             }
  9.            
  10.             if (xmlhttp.readyState == 4 && (xmlhttp.status == 200 || window.location.href.indexOf ("http") == - 1))
  11.             {
  12.                 var nueva_img = document.createElement('img');
  13.                 nueva_img.src = xmlhttp.responseText;
  14.                 nueva_img.alt = 'Mapa';
  15.                
  16.                 nueva_img.addEventListener('load', function()
  17.                 {
  18.                     if(nueva_img.complete)
  19.                     {
  20.                         document.getElementById('mapa_imagen').src = nueva_img.src;
  21.                         document.getElementById('loadingMap').style.visibility = 'hidden';
  22.                     }
  23.                 }, false);
  24.                
  25.             }
  26.         };
  27.        
  28.         xmlhttp.open("GET", url, true);
  29.         xmlhttp.send(null);

Este código funciona correctamente, pero no he podido determinar la manera de implementar el attachEvent correctamente.

Espero me puedan indicar cómo.

Nota: probé quitandole el tercer valor (false) que se le envía a la función, pero tampoco funciona.

Gracias y saludos!
__________________
Gmail : [email protected]
Twitter: @heiroon

I'm back!