Foros del Web » Programando para Internet » Javascript »

Onmouseover en IMG

Estas en el tema de Onmouseover en IMG en el foro de Javascript en Foros del Web. Buenas !!! Cuando pego el siguiento codigo: <script language="javascript"> window.onload = function() { var lis = document.getElementsByTagName("img"); for (var i=0;i<lis.length;i++) { lis[i].onmouseover = function() { ...
  #1 (permalink)  
Antiguo 22/05/2009, 12:14
 
Fecha de Ingreso: marzo-2008
Mensajes: 29
Antigüedad: 16 años, 2 meses
Puntos: 1
Onmouseover en IMG

Buenas !!!

Cuando pego el siguiento codigo:

<script language="javascript">
window.onload = function()
{
var lis = document.getElementsByTagName("img");

for (var i=0;i<lis.length;i++) {
lis[i].onmouseover = function()
{
cambia_imagen(this);
};
}
};

</script>

toda imagen que tenga en la web, me la cambia por otra al apoyar el raton PEROOOO solo si usas IE.

Con Mozilla o Crhome no lo hace y quiero saber como puedo solucionarlo. Es decir, esta misma funcion o muy parecida que me añada en todas las imagenes de forma automatica Onmouseover pero que funcione con cualquier navegador.

Gracias de antemano!
  #2 (permalink)  
Antiguo 22/05/2009, 12:59
Avatar de buzu  
Fecha de Ingreso: octubre-2006
Ubicación: San Francisco, CA
Mensajes: 2.168
Antigüedad: 17 años, 6 meses
Puntos: 122
Respuesta: Onmouseover en IMG

tienes que poner la función cambia_imagen para que podamos ver el código. de otra manera no sabemos que puede andar mal.

Saludos.
__________________
twitter: @imbuzu
  #3 (permalink)  
Antiguo 22/05/2009, 13:27
 
Fecha de Ingreso: marzo-2008
Mensajes: 29
Antigüedad: 16 años, 2 meses
Puntos: 1
Respuesta: Onmouseover en IMG

He suprimido la funcion Cambia_imagen y el codigo lo he dejado asi:


<script language="javascript">
window.onload = function()
{
var lis = document.getElementsByTagName("img");

for (var i=0;i<lis.length;i++) {
lis[i].onmouseover = function()
{
this.src='archivos/11.gif';
};
}
};
</script>


Y con IE cambia la imagen perfectamente y con el resto de navegadores NO
  #4 (permalink)  
Antiguo 22/05/2009, 13:36
Avatar de buzu  
Fecha de Ingreso: octubre-2006
Ubicación: San Francisco, CA
Mensajes: 2.168
Antigüedad: 17 años, 6 meses
Puntos: 122
Respuesta: Onmouseover en IMG

intenta cambiando this.src por lis[i].src aun que no estoy seguro que ese sea el problema.
__________________
twitter: @imbuzu
  #5 (permalink)  
Antiguo 22/05/2009, 13:41
 
Fecha de Ingreso: marzo-2008
Mensajes: 29
Antigüedad: 16 años, 2 meses
Puntos: 1
Respuesta: Onmouseover en IMG

Nada.

Ocurre lo mismo. Con IE funciona pero con el resto no.

¿Alguna Solucion PLEASE....?
  #6 (permalink)  
Antiguo 22/05/2009, 14:00
Avatar de buzu  
Fecha de Ingreso: octubre-2006
Ubicación: San Francisco, CA
Mensajes: 2.168
Antigüedad: 17 años, 6 meses
Puntos: 122
Respuesta: Onmouseover en IMG

El error está en otro lado, acabo de probar el código tal como lo tienes y no me ha dado problema alguno:
Código html:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4.     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5.     <title>\</title>
  6.     <script language="javascript">
  7. window.onload = function()
  8. {
  9. var lis = document.getElementsByTagName("img");
  10.  
  11. for (var i=0;i<lis.length;i++) {
  12. lis[i].onmouseover = function()
  13. {
  14. this.src='http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_pos.gif';
  15. };
  16. }
  17. };
  18. </head>
  19. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  20. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  21. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  22. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  23. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  24. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  25. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  26. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  27. <img src="http://static.forosdelweb.com/fdwtheme/images/reputation/reputation_off.gif" alt="" /><br />
  28. </body>
  29. </html>

Probado en Firefox
__________________
twitter: @imbuzu
  #7 (permalink)  
Antiguo 22/05/2009, 15:36
 
Fecha de Ingreso: marzo-2008
Mensajes: 29
Antigüedad: 16 años, 2 meses
Puntos: 1
Respuesta: Onmouseover en IMG

Perfect! Muchas Gracias Buzu.

No se donde estaba el error, porque lo he comparado integramente con el tuyo y es identico pero copie el tuyo y funciona.

Gracias!
  #8 (permalink)  
Antiguo 22/05/2009, 16:21
Avatar de buzu  
Fecha de Ingreso: octubre-2006
Ubicación: San Francisco, CA
Mensajes: 2.168
Antigüedad: 17 años, 6 meses
Puntos: 122
Respuesta: Onmouseover en IMG

probalemente tu cache te estava jugando una broma jajaja
__________________
twitter: @imbuzu
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:03.