Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/05/2014, 17:08
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 1 mes
Puntos: 292
Respuesta: Rotador de imagenes en Javascript se vuelve loco

Empezaria mas o menos asi:

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <title>Test de @Italico76</title>
  4. <style>
  5.     body {background-color: #000;} 
  6.  
  7.     #slider_images
  8.    {
  9.         width:350px;
  10.         height:350px;
  11.         background-color: #bbb;
  12.         border: red 2px;
  13.         position:relative;
  14.    }
  15.    
  16.    img {display:none;}
  17.    
  18. </style>
  19. </head>
  20. <body>
  21.  
  22. <div id="slider_images">
  23.    <img src="images/2.jpg" width="150px" height="150px"/>
  24.    <img src="images/3.jpg" width="150px" height="150px"/>
  25.    <img src="images/4.jpg" width="150px" height="150px"/>
  26.    <img src="images/5.jpg" width="150px" height="150px"/>
  27.    <img src="images/6.jpg" width="150px" height="150px"/>
  28. </div>
  29.  
  30.  
  31. <script>
  32.     function init()
  33.     {
  34.         var imageContainer = document.getElementById("slider_images");
  35.         var imageContainerChilds = imageContainer.childNodes;          
  36.        
  37.         var img_cont = 0;
  38.         var img_contenedor_new = new Array;
  39.        
  40.         for (i = 0; i < imageContainerChilds.length; i++)
  41.         {
  42.             // me quedo solo con las etiquetas <img>
  43.             if (typeof(imageContainerChilds[i].src) !='undefined')
  44.             {
  45.                 // les asigno id para identificarlas (no se si tenian!)
  46.                 imageContainerChilds[i].id=img_cont;
  47.                 img_cont++;                
  48.             }
  49.         }      
  50.     }
  51.      
  52.     function rotateImages(){
  53.         // hacer!
  54.     }    
  55.      
  56.     window.onload = function()
  57.     {
  58.         init();
  59.         rotateImages();
  60.     }
  61. </script>
  62. </body>
  63. </html>
__________________
Salu2!