PDA

View Full Version : سوال: رنگي كردن متن



Iran58
شنبه 09 آبان 1388, 12:05 عصر
سلام
يك متن نوشته ايم كه رنگ آن سياه است حال چگونه مي توانيم حرف به حرف از اول تا آخررنگ آن تبديل به قرمزشود.

kohyar
شنبه 09 آبان 1388, 16:45 عصر
دوست عزيز اينكار با جاوا اسكريپت امكان پذير هستش



<SCRIPT language=JavaScript1.2>



var message="your text is here"
var neonbasecolor="Blue"
var neontextcolor="red"
var flashspeed=50 //in milliseconds
///No need to edit below this line/////
var n=0
if (document.all||document.getElementById){
document.write('<font color="'+neonbasecolor+'">')
for (m=0;m<message.length;m++)
document.write('<span id="neonlight'+m+'">'+message.charAt(m)+'</span>')
document.write('</font>')
}
else
document.write(message)
function crossref(number){
var crossobj=document.all? eval("document.all.neonlight"+number) : document.getElementById("neonlight"+number)
return crossobj
}
function neon(){
//Change all letters to base color
if (n==0){
for (m=0;m<message.length;m++)
//eval("document.all.neonlight"+m).style.color=neonbasecolor
crossref(m).style.color=neonbasecolor
}
//cycle through and change individual letters to neon color
crossref(n).style.color=neontextcolor
if (n<message.length-1)
n++
else{
n=0
clearInterval(flashing)
setTimeout("beginneon()",500)
return
}
}
function beginneon(){
if (document.all||document.getElementById)
flashing=setInterval("neon()",flashspeed)
}
beginneon()
</SCRIPT>