PDA

View Full Version : Neon Text in JS



jgk
09-08-2005, 12:05 PM
Hello,
Im using the neon text javascript as given in

http://www.dynamicdrive.com/dynamicindex10/neontext.htm

Its working fine...Its also kewl..
But the thing is whn i try to put it as JS,include it and use it..I'm not able to do that...
Im also not sure why this is happening?I have'nt used much of scripts for other than validations...

Here is the JS i modified
-------------------------------------------------------------------------
function glows(){

var message="Value Fishbone";
var neonbasecolor="gray";
var neontextcolor="black";
var flashspeed=100 //in milliseconds

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

var n=0
if (document.all||document.getElementById){
document.write('<font color="'+neonbasecolor+'">')
alert("Inside if");
for (m=0;m<message.length;m++)
document.write('<span id="neonlight'+m+'">'+message.charAt(m)+'</span>')
document.write('</font>')
}
else{
alert("Inside 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()",1500)
return
}
}

function beginneon(){
if (document.all||document.getElementById)
flashing=setInterval("neon()",flashspeed)
}
beginneon()
}
--------------------------------------------------------------------------
And following is the HTML im using...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>.:Glow Text Example:.</TITLE>
<script language="JavaScript" src="glow.js"></script>
</HEAD>
<BODY>
<script language="JavaScript">
glows();
</script>
</BODY>
</HTML>

Im not sure why this works in INLINE and not whn i put in JS n include it...

Please some do help me...Thanks in advance

Regds,
JGK