Fading text using javascript, best for advertising your offer.

<div id=”fader” style=”font:18px Arial bold;width:100%;color:rgb(255,255,255)”></div>

<script language=”JavaScript1.2″>
hexinput=255  // Initial color value.
var inc=-1 //increment variable

function fadingtext(){           
if(hexinput>0) { 
hexinput-=11; // increase color value
document.getElementById(“fader”).style.color=”rgb(“+hexinput+”,”+hexinput+”,”+hexinput+”)”; // Set color value.
setTimeout(“fadingtext()”,120); 
}
else
hexinput=255  //reset hex value
}

function changetext(){
if (!document.getElementById) return
inc++
if (inc==0)
document.getElementById(“fader”).innerHTML=”Welcome to My World”
else if (inc==1)
document.getElementById(“fader”).innerHTML=”Visit my blog…”
else{
document.getElementById(“fader”).innerHTML=”Enjoy your stay here”
inc=-1
}
fadingtext()
setTimeout(“changetext()”,4000)
}

window.onload=changetext

</script>

Advertisements

One thought on “Fading text using javascript, best for advertising your offer.

  1. Pingback: Mattedsic.Com » Fading text using javascript, best for advertising your offer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s