Thanks! Your code may solve the problems I'm having with my own attempt. I found a dynamicdrive code for fading in text using rgb colors and tweaged it....BUT the first text comes out great, beautiful, the second is real stuttered and the third comes out fast and only part of the time. Take a look. By the way, if I alter someone else's code do I still need to credit the code to them even though I've made a bunch of changes? When does that switch of ownership take place?
HTML Code:
<html>
<head>
<script language="javascript" type="text/javascript">
/***********************************************
* Derived from Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var tnum = "1";
var t = new Array();
t[1] = "ABOUT US";
t[2] = "SERVICES";
t[3] = "EXPERIENCE";
t[4] = "CONTACT US";
var delay=2000; //delay before next message displays
var totalsteps=30;
var stepdelay=40; //time of single step
var s_color=new Array(0,0,0);
var e_color=new Array(255,255,255);
function fadein()
{
if (document.getElementById("text"+tnum) != null)
{
var text_fade=document.getElementById("text"+tnum);
text_fade.style.color="rgb("+s_color[0]+","+s_color[1]+","+s_color[2]+")" //set start color of text
text_fade.innerHTML=t[tnum];
setcolor(1,15); //call function setcolor with steps input
}
}
function setcolor(step)
{
if(step<=totalsteps)
{
document.getElementById("text"+tnum).style.color=getcolor(step);
step++;
var fadecounter=setTimeout("setcolor("+step+")",stepdelay); //set rate for each step
}
else //if colors have reached total steps, clear out previous loop and set to end color
{
clearTimeout(fadecounter);
document.getElementById("text"+tnum).style.color="rgb("+e_color[0]+","+e_color[1]+","+e_color[2]+")";
tnum++
}
if(tnum<t.length)
{
setTimeout("fadein()", delay); //go through fadein again (next text) at the given rate
}
}
function getcolor(step)
{
var n_color=new Array(3);
var diff=(s_color[0]-e_color[0]);
n_color[0]=s_color[0]+(Math.round((Math.abs(diff)/totalsteps))*step);
return ("rgb("+n_color[0]+", "+n_color[0]+", "+n_color[0]+")");
}
onload=fadein;
</script>
</head>
<body bgcolor="black" text="white">
<div id="text1" style="position:absolute; left:460px; top:440px; width:250px; height: 50px; font-family: Arial; font-size: 18pt; font-weight: bold"></div>
<div id="text2" style="position:absolute; left:460px; top:500px; width:250px; height: 50px; font-family: Arial; font-size: 18pt; font-weight: bold"></div>
<div id="text3" style="position:absolute; left:460px; top:560px; width:250px; height: 50px; font-family: Arial; font-size: 18pt; font-weight: bold"></div>
<div id="text4" style="position:absolute; left:460px; top:620px; width:250px; height: 50px; font-family: Arial; font-size: 18pt; font-weight: bold"></div>
</body>
</html>
Bookmarks