Hasard + delete juste après

arbilus Messages postés 93 Date d'inscription dimanche 6 juin 2010 Statut Membre Dernière intervention 20 avril 2015 - 28 mai 2010 à 15:38
phpAnonyme Messages postés 392 Date d'inscription mercredi 28 octobre 2009 Statut Membre Dernière intervention 23 mars 2012 - 1 juin 2010 à 18:31
<SCRIPT LANGUAGE="Javascript"><!--

// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************

function text() {
};

text = new text();
number = 0;

// textArray
text[number++] = "Random text string 1."
text[number++] = "Random text string 2."
text[number++] = "Random text string 3."
text[number++] = "Random text string 4."
text[number++] = "Random text string 5."
text[number++] = "etc..."
// keep adding items here...

increment = Math.floor(Math.random() * number);

document.write(text[increment]);

//--></SCRIPT>

Bonjours, ceci est un code qui permet d'afficher une des textes au hasard, mais j'aurais aimer faire en sorte qu'une fois le texte affiché celui-ci s'efface du contenu du fichier. Et là, impossible de trouver..

1 réponse

phpAnonyme Messages postés 392 Date d'inscription mercredi 28 octobre 2009 Statut Membre Dernière intervention 23 mars 2012 55
1 juin 2010 à 18:31
Salut,

function Delete()
{
document.write('');
}

function AffichText() 
{

var Tabtext = new Array("Random text string 1.", "Random text string 2.", "Random text string 3.", "Random text string 4.", "Random text string 5.");

text = Math.floor(Math.random() * Tabtext.length);

document.write(Tabtext[text]); 

setTimeout("Delete()",9000);

}


Le text s'affichera pendant 9 secondes(9000millièmes de secondes) puis s'effacera (Tu peux jour sur le temps naturellement).

J'ai modifié un peu ton code pour qu'il "plus propre"

Voilà !

______________________________________________________________________
0
Rejoignez-nous