alex242 Posted September 1, 2010 Share Posted September 1, 2010 The problem may not be so obvious, but it still should not be happening. The rate of the 'setTimout' is set so slow so you can see the problem more clearly. The problem is that sometimes the color repeats itself, causing a visual 'hang' in the color change of the text. I have written some code that should be working to stop this issue, but it does not appear to be working. What is wrong? <html><head><script type='text/javascript'>var colors = new Array('black','red','green','blue','brown','chocolate','purple','gray','olive');function hellow(y){x = Math.floor(Math.random()*10);while(x == y){x = Math.floor(Math.random()*10);}document.getElementById('hello').style.color = colors[x]var t = setTimeout('hellow(x)',500);}</script></head><body onload='hellow(1)'><h1 id='hello'>HELLO WORLD!</h1></body></html> Link to comment Share on other sites More sharing options...
alex242 Posted September 1, 2010 Author Share Posted September 1, 2010 uhh... Sorry everybody... I'm an Idiot.It was working just fine. I just didn't have a ninth color name listed, so it appeared to hang when the random number x equaled 9.Sorry again...this thread should be closed so It doesn't waste anyone else's time. Link to comment Share on other sites More sharing options...
MrFish Posted September 1, 2010 Share Posted September 1, 2010 Add [sOLVED] to the title of your first post. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.