minow Posted May 25, 2006 Share Posted May 25, 2006 this is my script. the problem isthe timeout is getting shorter in every loop for some reason.fadetext() - changing the color to yellow and the calling to fadetext2()fadetext2() - changing the color to black and then calling fadetext()thanks for every help <html><head><script language="JavaScript1.2">hex=0; hex2=0;hex3=0;function fadetext(){ if(hex<250 || hex2<250) { hex+=10; hex2+=10; document.getElementById("sample").style.color="rgb("+hex+","+hex2+","+hex3+")"; setTimeout("fadetext()",100); } if (hex == 250 || hex2 == 250) { setTimeout("fadetext2()",100); }}function fadetext2(){ if(hex3>0 || hex2>0) { hex-=10; hex2-=10; document.getElementById("sample").style.color="rgb("+hex+","+hex2+","+hex3+")"; setTimeout("fadetext2()",100); } if (hex == 0 || hex2 == 0) { setTimeout("fadetext()",100); }}</script></head><body><div id="sample" style="width:100%"><h3>Hey</h3></div><button onClick="fadetext()">Fade Text</button></body></html> Link to comment Share on other sites More sharing options...
Webworldx Posted May 26, 2006 Share Posted May 26, 2006 Few else's fixed it: <html><head><script language="JavaScript1.2">hex=0; hex2=0;hex3=0;var m = 0;function fadetext(){ if( hex<250 || hex2<250) { hex+=10; hex2+=10; document.getElementById("sample").style.color="rgb("+hex+","+hex2+","+hex3+")"; setTimeout("fadetext()",100); } else if (hex == 250 || hex2 == 250){ setTimeout("fadetext2()",100); }}function fadetext2(){ if(hex3>0 || hex2>0) { hex-=10; hex2-=10; document.getElementById("sample").style.color="rgb("+hex+","+hex2+","+hex3+")"; setTimeout("fadetext2()",100); } else if (hex == 0 || hex2 == 0){ setTimeout("fadetext()",100); }}</script></head> Link to comment Share on other sites More sharing options...
minow Posted May 26, 2006 Author Share Posted May 26, 2006 thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now