Tema: background
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/09/2011, 08:01
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: background

Me parece que esto se adapta mejor a lo que necesitas, simplemente cambia el background-image del body

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">
  4. <title>Cambiar background aleatoriamente cada n segundos</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <style type="text/css">
  7. /* definimos un background por defecto */
  8. body {
  9. background-image: url('sfondo01.jpg');
  10. }
  11. <script type="application/javascript">
  12. // aqui definis la lista de imágenes
  13. var fondos = ['sfondo01.jpg', 'sfondo02.gif', 'sfondo03.jpg', 'sfondo04.jpg'];
  14. var fondo_actual = 0;
  15. // aqui hacemos la rotación
  16. var CambiarFondo = function(){
  17. if (fondo_actual == fondos.length) fondo_actual = 0;
  18. document.body.style.backgroundImage = 'url('+ fondos[fondo_actual++]+ ')';
  19. }
  20. //aqui definís el tiempo en milisegundos
  21. window.setInterval(CambiarFondo, 3000);
  22. </head>
  23. <h1>Cambiar background aleatoriamente cada n segundos</h1>
  24. </body>
  25. </html>

demo:

http://foros.emprear.com/jsdemo/rota...torotarbg.html

saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.