Neon Sign

[Total: 0    Average: 0/5]

This shows how to have text change color – over and over.

Body Code:

<script language="JavaScript1.2">

var message="This text changes color."
var neonbasecolor="gray"
var neontextcolor="yellow"
var flashspeed=100  //in milliseconds

///No need to edit below this line/////

var n=0
if (document.all){
document.write('<font color="'+neonbasecolor+'">')
for (m=0;m<message.length;m++)
document.write('<span id="neonlight">'+message.charAt(m)+'</span>')
document.write('</font>')

//cache reference to neonlight array
var tempref=document.all.neonlight
}
else
document.write(message)

function neon(){

//Change all letters to base color
if (n==0){
for (m=0;m<message.length;m++)
tempref[m].style.color=neonbasecolor
}

//cycle through and change individual letters to neon color
tempref[n].style.color=neontextcolor

if (n<tempref.length-1)
n++
else{
n=0
clearInterval(flashing)
setTimeout("beginneon()",1500)
return
}
}

function beginneon(){
if (document.all)
flashing=setInterval("neon()",flashspeed)
}
beginneon()
function doIt(c,tf)
{
if(tf)
neonbasecolor=c;
else
neontextcolor=c;
}

</script>
<form>
<input type=button value="red-base" onclick=doIt('red',true)>
<input type=button value="red-text" onclick=doIt('red',false)>
<input type=button value="yellow-base" onclick=doIt('yellow',true)>
<input type=button value="yellow-text" onclick=doIt('yellow',false)>
<input type=button value="blue-base" onclick=doIt('blue',true)>
<input type=button value="blue-text" onclick=doIt('blue',false)>
<input type=button value="green-base" onclick=doIt('green',true)>
<input type=button value="green-text" onclick=doIt('green',false)>
</form>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *