Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/06/2011, 19:14
Avatar de Naahuel
Naahuel
 
Fecha de Ingreso: marzo-2011
Ubicación: localhost
Mensajes: 796
Antigüedad: 13 años, 1 mes
Puntos: 192
Respuesta: Cambiar imagen cada X segundos

Acá tenés un ejemplo sencillo:

Tenés que editar la variable "tiempo" y el array de imágenes.

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. function rotar_imagen(){
  3.   var tiempo = 1000;//tiempo en milisegundos
  4.   var arrImagenes = ['http://3.bp.blogspot.com/_bVS2bdfO4As/RkvjtoibTxI/AAAAAAAAAso/c1Y93BkfBrs/s320/01_HomerSimpson.gif','http://www.seeklogo.com/images/H/Homer_Butt_Homero_Trasero-logo-807B1B6A2E-seeklogo.com.gif', 'http://2.bp.blogspot.com/__UX7GOPM7wI/SeAOEWkWsWI/AAAAAAAAAWQ/0xaOwEIue_I/s200/Homer_Simpson.png'];
  5.  
  6.   _img = document.getElementById('rotativo');
  7.  
  8.   //cargar la 1er imagen
  9.   _img.src = arrImagenes[0];
  10.   var i=1;
  11.   setInterval(function(){
  12.     _img.src = arrImagenes[i];
  13.     i = (i == arrImagenes.length-1)? 0 : (i+1);
  14.   }, tiempo);
  15. }
  16. </head>
  17. <body onload="rotar_imagen();">
  18.   <img id="rotativo"  />
  19. </body>
  20. </html>
__________________
nahueljose.com.ar

Última edición por Naahuel; 15/06/2011 a las 19:28