Visualizzazione dei risultati da 1 a 3 su 3

Discussione: problema SetInterval

  1. #1

    problema SetInterval

    Salve, avendo questi codici per far in modo che una frase cambi ogni 5 secondi, non capisco perchè setInterval non funzioni.. I codici sono i seguenti:

    codice:
     <HTML>
    <HEAD>
    <TITLE></TITLE>
    <script type ="text/javascript">
    function getQuote()
    {
    
    var mtQuotes = new Array();
    
    mtQuotes[0] = "I smoke in moderation, only one cigar at a time.";
    
    mtQuotes[1] = "Be careful of reading health books, you might die of a misprint.";
    
    mtQuotes[2] = "Man is the only animal that blushes or needs to.";
    
    mtQuotes[3] = "Clothes make the man. Naked people have little or no influence on society.";
    
    mtQuotes[4] = "One of the most striking differences between a cat and a lie is that a cat has only nine lives.";
    
    var randValue = Math.floor(Math.random() * mtQuotes.length);
    document.write(mtQuotes[randValue]);
    }
    
    window.setInterval("getQuote()", 500);
    
    </script>
    </HEAD>
    <BODY onload="getQuote();">
    </BODY>
    </HTML>
    Ho provato anche senza window. prima ma niente..
    Social Network in costruzione.. Misto tra Twitter e Facebook.. Twitbook o facetter?

  2. #2
    Utente di HTML.it
    Registrato dal
    Apr 2000
    Messaggi
    938
    Ciao,

    codice:
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    <script type ="text/javascript">
    function getQuote()
    {
    
    var mtQuotes = new Array();
    
    mtQuotes[0] = "I smoke in moderation, only one cigar at a time.";
    
    mtQuotes[1] = "Be careful of reading health books, you might die of a misprint.";
    
    mtQuotes[2] = "Man is the only animal that blushes or needs to.";
    
    mtQuotes[3] = "Clothes make the man. Naked people have little or no influence on society.";
    
    mtQuotes[4] = "One of the most striking differences between a cat and a lie is that a cat has only nine lives.";
    
    randValue = Math.floor(Math.random() * mtQuotes.length);
    
    document.getElementById("pippo").innerHTML=mtQuotes[randValue];
    
    }
    window.setInterval("getQuote()", 5000);
    </script>
    </HEAD>
    <BODY onload="getQuote();">
    
    <div id="pippo"></div>
    
    </BODY>
    </HTML>

    M.

  3. #3
    Grazie mille
    Social Network in costruzione.. Misto tra Twitter e Facebook.. Twitbook o facetter?

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.