Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/05/2014, 12:20
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 1 mes
Puntos: 292
Respuesta: ¿Como usar este script para rotar textos mas de una vez por pagina?

Pues.. no se donde quieras tener los textos... pero dentro la funcion seria muy desprolijo, mejor asi

Código Javascript:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  2. <html>
  3. <head>
  4. <style>
  5.     .textToRead {display:none;}
  6. </style>
  7.  
  8. <script>
  9.     /*
  10.         @author: Pablo Bozzolo (de modificaciones*)
  11.         (autor original desconocido)
  12.     */
  13.     var rotatingTextElement;
  14.     var rotatingText = new Array();
  15.     var cnt = 0;
  16.  
  17.     function initRotateText() {
  18.         rotatingTextElement = document.getElementById("textToChange"); 
  19.         aLeer = document.getElementsByClassName("textToRead");
  20.        
  21.         // para la primera vez
  22.         rotatingTextElement.innerHTML = aLeer[0].innerHTML;
  23.  
  24.         for (var i = 0; i < aLeer.length; i++)    
  25.             rotatingText.push(aLeer[i].innerHTML);
  26.        
  27.         setInterval(rotateText, 1500);
  28.     }
  29.    
  30.     function rotateText() {
  31.         cnt++;
  32.         if(cnt >= rotatingText.length) {
  33.             cnt = 0;
  34.         }
  35.         rotatingTextElement.innerHTML = rotatingText[cnt];
  36.     }
  37.    
  38. </script>
  39. </head>
  40. <body onload="initRotateText();">
  41.    
  42.     <p class="textToRead"/>
  43.     Dependency Injection: Huh?
  44.  
  45.     Chances are, at some point in your learning, you've come across the term, "dependency injection." If you're still relatively early in your learning, you likely formed a confused expression and skipped over that part. Still, this is an important aspect of writing maintainable (and testable) code. In this article, I'll explain it in as simple a way as I'm capable of.
  46.        
  47.     <p class="textToRead"/>
  48.     Otro texto largo y aburridor
  49.        
  50.     <p class="textToRead"/>
  51.     Otro texto masss largo y aburridor
  52.        
  53.     <p class="textToRead">
  54.     Otro texto masss largo y mssssssss aburridor!!!
  55.     <p/>   
  56.    
  57.     <!-- aca se muestra : -->
  58.     <div id="textToChange">
  59.    
  60.     </div>
  61.    
  62. </body>
  63. </html>

Hay varios elementos (DIV, P ... da igual el tipo) ... de clase textToRead, crea los que necesites!
__________________
Salu2!

Última edición por Italico76; 21/05/2014 a las 12:51