Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it L'avatar di mdx92
    Registrato dal
    Sep 2007
    Messaggi
    116

    Testo random ogni tot secondi

    Salve a tutti,
    ho bisogno di un javascript che mi cambi frase dopo un tot di secondi...in rete ho trovato qualcosa, ma tutto graficamente personalizzato, a me servirebbe un normale testo su sfondo "trasparente" con font arial che cambi frase (3 o 4) ogni 3 secondi.

    Premetto, sono totalmente a digino di java! chiedo se possibile la cortesia ad uno di voi di crearmi questo (credo) banale script!

    Grazie a tutti!
    Ennio Campitelli

  2. #2

  3. #3

  4. #4
    Utente di HTML.it L'avatar di mdx92
    Registrato dal
    Sep 2007
    Messaggi
    116
    GRAZIEEE era giorni che lo cercavo!! grazie davvero!

  5. #5
    Utente di HTML.it L'avatar di mdx92
    Registrato dal
    Sep 2007
    Messaggi
    116
    ragazzi se io ho questo codice html:

    Codice PHP:
    <html>
    <
    head>
        <
    script type="text/javascript" src="alt.js"></script>
    </head>
    <body>
                 <form name="change">
                       <textarea class="test" name="descript" wrap="virtual">
                 </form>
    </body>
    </html> 

    e questa pagina js

    Codice PHP:
    /* This script and many more are available free online at
    The JavaScript Source!! [url]http://javascript.internet.com[/url]
    Created by: Sandeep Gangadharan | [url]http://sivamdesign.com/scripts/[/url] */
    var text 0;

    var 
    message=new Array();
      
    message[0] = "Benvenuti su HTML.it"
      
    message[1] = "Sezione Javascript"
      
    message[2] = "Scaricate centinaia di script"
      
    message[3] = "Arrivederci..."

    function changeText() {
      if (
    message.length 0) {
        
    document.change.descript.value=message[text];
        
    text++;
      }
      if (
    text == 4) {text 0; }  // change the # 4 at the left to the maximum # of message lines you want included
        
    window.setTimeout("changeText()"3500); }  // change the # on the left to adjust the speed of the
                                                   // scroll. The smaller the # the faster the speed

    // Multiple onload function created by: Simon Willison
    // [url]http://simon.incutio.com/archive/2004/05/26/addLoadEvent[/url]
    function addLoadEvent(func) {
      var 
    oldonload window.onload;
      if (
    typeof window.onload != 'function') {
        
    window.onload func;
      } else {
        
    window.onload = function() {
          if (
    oldonload) {
            
    oldonload();
          }
          
    func();
        }
      }
    }

    addLoadEvent(function() {
      
    changeText();
    }); 
    Questo script così com'è mi stampa a video delle frasi NON random dopo un tot di secondi...però me le stampa dentro una textarea, io vorrei che comparissero come un normale testo.
    Come si fa a richiamare quella funzione al di fuori della text area? grazie per l'aiuto!

  6. #6
    invece di usare una textarea, usa un qualsiasi tag contenitore di testo:

    div, span, p.
    Codice PHP:
    <form name="change"
                       <
    span class="test" name="descript" wrap="virtual" id="descript"
                 </
    form
    mentre nel javascript:

    Codice PHP:
    document.change.descript.innerText message[text]; 

  7. #7
    Utente di HTML.it L'avatar di mdx92
    Registrato dal
    Sep 2007
    Messaggi
    116
    Originariamente inviato da Gluck74
    invece di usare una textarea, usa un qualsiasi tag contenitore di testo:

    div, span, p.
    Codice PHP:
    <form name="change"
                       <
    span class="test" name="descript" wrap="virtual" id="descript"
                 </
    form
    mentre nel javascript:

    Codice PHP:
    document.change.descript.innerText message[text]; 

    Ciao! ho midificato così:

    Pagina Html:

    Codice PHP:
    <html
    <
    head
        <
    script type="text/javascript" src="alt.js"></script> 
    </head> 
    <body> 
    <form name="change"> 
                       <span class="test" name="descript" wrap="virtual" id="descript"> 
                 </form>

    </body> 
    </html> 
    Pagina java

    Codice PHP:
    /* This script and many more are available free online at 
    The JavaScript Source!! [url="http://javascript.internet.com"][url]http://javascript.internet.com[/url][/url] 
    Created by: Sandeep Gangadharan | [url="http://sivamdesign.com/scripts/"][url]http://sivamdesign.com/scripts/[/url][/url] */ 
    var text 0

    var 
    message=new Array(); 
      
    message[0] = "Benvenuti su HTML.it" 
      
    message[1] = "Sezione Javascript" 
      
    message[2] = "Scaricate centinaia di script" 
      
    message[3] = "Arrivederci..." 

    function changeText() { 
      if (
    message.length 0) { 
        
    document.change.descript.innerText=message[text];
        
    text++; 
      } 
      if (
    text == 4) {text 0; }  // change the # 4 at the left to the maximum # of message lines you want included 
        
    window.setTimeout("changeText()"3500); }  // change the # on the left to adjust the speed of the 
                                                   // scroll. The smaller the # the faster the speed 

    // Multiple onload function created by: Simon Willison 
    // [url="http://simon.incutio.com/archive/2004/05/26/addLoadEvent"][url]http://simon.incutio.com/archive/20...26/addLoadEvent[/url][/url] 
    function addLoadEvent(func) { 
      var 
    oldonload window.onload
      if (
    typeof window.onload != 'function') { 
        
    window.onload func
      } else { 
        
    window.onload = function() { 
          if (
    oldonload) { 
            
    oldonload(); 
          } 
          
    func(); 
        } 
      } 


    addLoadEvent(function() { 
      
    changeText(); 
    }); 
    Ma non funziona mi da errore alla riga 15 dello script java mi dice che:

    Codice PHP:
    document.change.descript 
    E' nullo o non'è un oggetto!!
    come mai??

  8. #8
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    cambia questo
    document.change.descript.innerText=message[text];
    in
    document.getElementById('descript').innerHTML=mess age[text];

    se il form non ti serve ...non ti serve!
    quindi questo
    <form name="change">
    <span class="test" name="descript" wrap="virtual" id="descript">
    </form>
    diventa solo
    <span class="test" id="descript"></span>

  9. #9
    Utente di HTML.it L'avatar di mdx92
    Registrato dal
    Sep 2007
    Messaggi
    116
    Grazie ora funziona!!

    Se servisse a qualcuno posto il codice delle due pagine funzionanti qui di seguito


    pagina.html :

    Codice PHP:
    <html
    <
    head
    <
    script type="text/javascript" src="alt.js"></script> 
    </head> 
    <body> 
    <span class="test" name="descript" wrap="virtual" id="descript"> 
    </body> 
    </html> 

    alt.js

    Codice PHP:
    /* This script and many more are available free online at 
    The JavaScript Source!! [url="http://javascript.internet.com"][url]http://javascript.internet.com[/url][/url] 
    Created by: Sandeep Gangadharan | [url="http://sivamdesign.com/scripts/"][url]http://sivamdesign.com/scripts/[/url][/url] */ 
    var text 0

    var 
    message=new Array(); 
      
    message[0] = "Benvenuti su HTML.it" 
      
    message[1] = "Sezione Javascript" 
      
    message[2] = "Scaricate centinaia di script" 
      
    message[3] = "Arrivederci..." 

    function changeText() { 
      if (
    message.length 0) { 
        
    document.getElementById('descript').innerHTML=message[text]; 
        
    text++; 
      } 
      if (
    text == 4) {text 0; }  // change the # 4 at the left to the maximum # of message lines you want included 
        
    window.setTimeout("changeText()"3500); }  // change the # on the left to adjust the speed of the 
                                                   // scroll. The smaller the # the faster the speed 

    // Multiple onload function created by: Simon Willison 
    // [url="http://simon.incutio.com/archive/2004/05/26/addLoadEvent"][url]http://simon.incutio.com/archive/20...26/addLoadEvent[/url][/url] 
    function addLoadEvent(func) { 
      var 
    oldonload window.onload
      if (
    typeof window.onload != 'function') { 
        
    window.onload func
      } else { 
        
    window.onload = function() { 
          if (
    oldonload) { 
            
    oldonload(); 
          } 
          
    func(); 
        } 
      } 


    addLoadEvent(function() { 
      
    changeText(); 
    }); 

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.