Here's a multiple use Neon Lights II:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>OO Neon Lights II - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
background-color:#000;
}
</style>
<script type="text/javascript">
//OO Neon Lights Text II from Neon Lights Text II by G.P.F. (gpf@beta-cc.de)
//visit http://www.beta-cc.de - This notice must remain for legal use
//Visit http://www.dynamicdrive.com for TOS
//Modified in http://www.dynamicdrive.com/forums/ by jscheuer1 for multiple use
///////////// No Need To Edit Here - See Below, in the Body /////////////
function neoII(id, nc, nc2, fs, fl, fl2, fp){
if(!document.getElementById&&!document.all) return;
this.id=id;//
this.el=document.getElementById? document.getElementById(id) : document.all[id];
this.message=this.el.innerHTML;
this.neonbasecolor=this.el.style.color;
this.neontextcolor=nc;
this.neontextcolor2=nc2;
this.flashspeed=fs;
this.flashingletters=fl;
this.flashingletters2=fl2;
this.flashpause=fp;
this.n=0;
for (var s='', m=0;m<this.message.length;m++)
s+='<span id="'+id+m+'">'+this.message.charAt(m)+'<\/span>';
this.el.innerHTML=s;;
this.beginneon();
}
neoII.prototype.crossref=function(number){
var crossobj=document.all? document.all[this.id+number] : document.getElementById(this.id+number);
return crossobj;
}
neoII.prototype.neon=function(){
//Change all letters to base color
if (this.n==0){
for (var m=0;m<this.message.length;m++)
this.crossref(m).style.color=this.neonbasecolor;
}
//cycle through and change individual letters to neon color
this.crossref(this.n).style.color=this.neontextcolor;
if (this.n>this.flashingletters-1)
this.crossref(this.n-this.flashingletters).style.color=this.neontextcolor2 ;
if (this.n>(this.flashingletters+this.flashingletters2)-1)
this.crossref(this.n-this.flashingletters-this.flashingletters2).style.color=this.neonbasecolor;
if (this.n<this.message.length-1)
this.n++;
else{
this.n=0;
clearInterval(this.flashing);
var c=this;
for (var m=0;m<this.message.length;m++)
this.crossref(m).style.color=this.neonbasecolor;
setTimeout(function(){c.beginneon();},this.flashpause);
return;
}
}
neoII.prototype.beginneon=function(){
var c=this;
this.flashing=setInterval(function(){c.neon();}, this.flashspeed);
}
</script>
</head>
<body>
<!-- Set Base Color as inline Style -->
<h2 id="neo1" style="color:gray;">Thank you for visiting Dynamic Drive!</h2>
<script type="text/javascript">
/* EXPLANATION OF TERMS /*
id - id of the element containing the message
neontextcolor - Text Color of main Flashing Section
neontextcolor2 - Text Color of section trailing main Flashing Section
flashspeed - speed of flashing in milliseconds
flashingletters - number of letters flashing in neontextcolor
flashingletters2 - number of letters flashing in neontextcolor2 (0 to disable)
flashpause - the pause between flash-cycles in milliseconds
*/
//USAGE: new neoII('id', 'neontextcolor', 'neontextcolor2', flashspeed, flashingletters, flashingletters2, flashpause)
new neoII('neo1', 'yellow', '#ffffa8', 100, 3, 1, 0);
</script>
<div id="neo2" style="color:#ccc;font:110% sans-serif">This one is green, in a division and faster, with a pause between cycles.</div>
<script type="text/javascript">
new neoII('neo2', '#a8ffa8', 'green', 50, 5, 2, 1000);
</script>
</body>
</html>
The code is well documented, design changes in the body only.
Bookmarks