advert

Flashing Neon Text

We've got a neat attention getter for you this week - we're calling it a Neon!

This script is quite simple, and is easy to implement, but needs to be used in moderation. As ever, here's the code, as fully annotated as possible.

<script language="JavaScript1.2">
/Flashing Neons/

///Edit the bits you need changed here////
var message="Put your message here - anything you like"
var neonbasecolor="blue"
var neontextcolor="red"
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 colour
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()

</script>

As usual, the code is on our example page - just cut and paste into your HTML code and edit the messages and colour - it's best used with a headline sized chunk of text, of course.

 

David Dorn

Keep up to Date with PPC

RSS feed icon

Add to Google

Free Sitemap Generator