Foros del Web » Programando para Internet » Javascript »

cambiar Background de mi web

Estas en el tema de cambiar Background de mi web en el foro de Javascript en Foros del Web. Hola muchachos, que tal? Bueno tengo un par de dudas 1.- como hago para que el bg de mi web se cambia cada cierto tiempo, ...
  #1 (permalink)  
Antiguo 02/05/2012, 20:35
 
Fecha de Ingreso: marzo-2012
Mensajes: 21
Antigüedad: 12 años, 1 mes
Puntos: 1
cambiar Background de mi web

Hola muchachos, que tal?
Bueno tengo un par de dudas
1.- como hago para que el bg de mi web se cambia cada cierto tiempo, pero no bruscamente, si no con algun efecto fade o algo por el estilo?
Ahora olvidando la primera pregunta
2.- como hago para que el bg de mi web cambie cada vez que entro nuevamente a mi web?
Gracias de antemano, ustedes siempre me salvan la vida =D
  #2 (permalink)  
Antiguo 03/05/2012, 09:53
 
Fecha de Ingreso: marzo-2007
Mensajes: 82
Antigüedad: 17 años, 1 mes
Puntos: 21
Respuesta: cambiar Background de mi web

para la pregunta 1
algo asi te sirve ?

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  4. <title>Insert title here</title>
  5. <script src="http://code.jquery.com/jquery-1.7.1.js" type="text/javascript" ></script>
  6.  
  7.     body {
  8.         margin: 0;
  9.         padding: 0;
  10.     }
  11.    
  12.     div#bg-1 {
  13.         position: absolute;
  14.         width: 100%;
  15.         height: 100%;
  16.         background-image: url('http://static2.grsites.com/archive/textures/dgren/dgren002.jpg');
  17.     }
  18.  
  19.     div#bg-2 {
  20.         position: absolute;
  21.         width: 100%;
  22.         height: 100%;
  23.         background-image: url('http://static3.grsites.com/archive/textures/blue/blue003.jpg');
  24.         display: none;
  25.     }
  26.    
  27.     div#bg-3 {
  28.         position: absolute;
  29.         width: 100%;
  30.         height: 100%;
  31.         background-image: url('http://static3.grsites.com/archive/textures/brown/brown007.jpg');
  32.         display: none;
  33.     }
  34.  
  35. <script type="text/javascript">
  36. var divIds = ["bg-1", "bg-2", "bg-3"];
  37. var currentIndex = 0;
  38. function changeBackground(country) {
  39.     var outDivId = divIds[currentIndex];
  40.     currentIndex = (currentIndex + 1 ) % divIds.length;
  41.     var inDivId = divIds[currentIndex];
  42.  
  43.     var outDiv = document.getElementById(outDivId);
  44.     var inDiv = document.getElementById(inDivId);
  45.     $(outDiv).fadeOut("slow");
  46.     $(inDiv).fadeIn("slow");
  47.  
  48.     setTimeout(changeBackground, 3000);
  49. }
  50.  
  51. setTimeout(changeBackground, 3000);
  52. </head>
  53.     <div id="bg-1"></div>
  54.     <div id="bg-2"></div>
  55.     <div id="bg-3"></div>
  56. </body>
  57. </html>
__________________
Hazle un favor a tu cerebro y juega Ajedrez online
Chess online

Etiquetas: css, jquery, fondo
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 16:14.