Yesideez Posted December 31, 2007 Share Posted December 31, 2007 First here's my Javascript: var colors=array('000000','110000','220000','330000','440000','550000','660000','770000','880000','990000','aa0000','bb0000','cc0000','dd0000','ee0000','ff0000','ee0000','dd0000','cc0000','bb0000','aa0000','990000','880000','770000','660000','550000','440000','330000','220000','110000','444444','888888','bbbbbb','ffffff','bbbbbb','888888','444444','END'); var i=0; function flash() { document.getElementById('flashme').style.color='#'+colors[i]; i++; if (colors[i]=='END') {i=0;} } setInterval('flash()',40); The HTML part is here: <body onload="flash();"> Then I use it by inserting it using this: <span id="flashme">ALL TICKETS HAVE NOW SOLD OUT</span> The Javascript itself is in a small file which is included like this: <script src="includes/functions.js"></script> First let me say I hate Javascript. I didn't want to use CSS to make it blink as I understand not all browsers support it, primarily early versions of IE. How true that is I've no idea. I avoid using Javascript where possible but the flashing I wanted I could only do using Javascript. After a bit of searching all I could find was a routine to alternate flashing two colors, a script to flash random colors or a routine to flash random colors stored in an array. Here is where the code is being used: http://beardedtheory.pictureinthesky.net/php/tickets.php When I first load the page the the color looks like it starts its cycle half-way through - am I right or is this just an illusion? Link to comment https://forums.phpfreaks.com/topic/83894-solved-my-text-flasher-doesnt-seem-to-start-at-array-index-0/ Share on other sites More sharing options...
phpQuestioner Posted December 31, 2007 Share Posted December 31, 2007 When I first load the page the the color looks like it starts its cycle half-way through - am I right or is this just an illusion? it looks like to me; that it is going through all of your colors very fastly, but test it and see - mix the colors up and use several: bright, medium, and dark colors through out the array. then set the interval to a longer amount of time and preview the script to see if it is going through each color. Link to comment https://forums.phpfreaks.com/topic/83894-solved-my-text-flasher-doesnt-seem-to-start-at-array-index-0/#findComment-426966 Share on other sites More sharing options...
Yesideez Posted December 31, 2007 Author Share Posted December 31, 2007 Damn good idea - gave it a try and it is starting at the beginning. I have the original text being placed on the screen in white which is giving the illusion. Link to comment https://forums.phpfreaks.com/topic/83894-solved-my-text-flasher-doesnt-seem-to-start-at-array-index-0/#findComment-426989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.