Visualizzazione dei risultati da 1 a 2 su 2

Discussione: cambiare colore script

  1. #1

    cambiare colore script

    codice:
    var list; // global list variable cache var tickerObj; // global tickerObj cache var hex = 255; function fadeText(divId) { if(tickerObj) { if(hex>0) { hex-=5; // increase color darkness tickerObj.style.color="rgb("+hex+","+hex+","+hex+")"; setTimeout("fadeText('" + divId + "')", fadeSpeed); } else hex=255; //reset hex value } } function initialiseList(divId) { tickerObj = document.getElementById(divId); if(!tickerObj) reportError("Could not find a div element with id \"" + divId + "\""); list = tickerObj.childNodes; if(list.length <= 0) reportError("The div element \"" + divId + "\" does not have any children"); for (var i=0; i<list.length; i++) { var node = list[i]; if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) tickerObj.removeChild(node); } run(divId, 0); } function run(divId, count) { fadeText(divId); list[count].style.display = "block"; if(count > 0) list[count-1].style.display = "none"; else list[list.length-1].style.display = "none"; count++; if(count == list.length) count = 0; window.setTimeout("run('" + divId + "', " + count+ ")", interval*1000); } function reportError(error) { alert("The script could not run because you have errors:\n\n" + error); return false; } var interval = 7; // interval in seconds var fadeSpeed = 40; // fade speed, the lower the speed the faster the fade. 40 is normal.
    Avrei questo codice in javascript, se tento di impostare un altro colore il fade non funziona più, ma funziona solo i testi che si alternano.
    come faccio a cambiargli colore?

    in particolare la parte interessata sarebbe questa, ma non riesco a modificarla!

    codice:
    if(tickerObj)
    { if(hex>0) { hex-=5; // increase color darkness tickerObj.style.color="rgb("+hex+","+hex+","+hex+")";
    setTimeout("fadeText('" + divId + "')", fadeSpeed);
    }
    else hex=255; //reset hex value
    }
    }
    hex è 255!

    mi esce sempre il colore nero!
    grazie.

  2. #2
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Tieni fisso uno o due delle componenti del colore e varia solo gli altri..

    tickerObj.style.color="rgb("+hex+",0,0)";

    oppure:

    tickerObj.style.color="rgb("+hex+","+hex+",255)";

    oppure:

    tickerObj.style.color="rgb("+hex+",0,"+hex+",)";

    oppure:

    ... a tua fantasia
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

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.