Acceler l'affichage de mon texte JavaS

Résolu/Fermé
niconovice Messages postés 954 Date d'inscription lundi 10 novembre 2008 Statut Membre Dernière intervention 3 mars 2014 - Modifié par niconovice le 23/04/2010 à 23:35
niconovice Messages postés 954 Date d'inscription lundi 10 novembre 2008 Statut Membre Dernière intervention 3 mars 2014 - 24 avril 2010 à 01:31
Salut est ce que quelqu'un pourrait m'aider a accelerer l'affichage de mon script svp :)

voir le resultat plutot lent ici: http://nicoweb.dixkey.com/lol/

la partie du code:

var i = 0;
var mon_span = document.getElementById('mon_span');
var mon_timer;
var txt = '111';
var txt1 = '222';
var txt2 = '333';

window.onload = function() {
    mon_span = document.getElementById('mon_span');
} 
function test()
{
			i = 0;
			clearInterval(mon_timer);
			mon_span.innerHTML = "";
		
			mon_timer = setInterval(ma_fonction, 100);
function ma_fonction()
{
			if(i < txt.length)
			{
			mon_span.innerHTML += txt.charAt(i++);
			}
			else
			{
			i = 0;
			clearInterval(mon_timer);
		}
	}
}


merci :)

Ps: je sais que mon code est tout vilain mais j'ai dejà lutter pour en arriver là alors chhhuuuuut :p



1 réponse

niconovice Messages postés 954 Date d'inscription lundi 10 novembre 2008 Statut Membre Dernière intervention 3 mars 2014 86
24 avril 2010 à 01:31
mon_timer = setInterval(ma_fonction, 1*10);
0