By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,379 Members | 1,709 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,379 IT Pros & Developers. It's quick & easy.

How exactly does a background fader script work???

P: n/a
Does a background fader work by...
A) Changing the color after a long 'loop' statement???

B) Changing the color, then waiting a bit, then changing the color
again???
To me it seems B would be less cpu/browser intensive. Does anyone know
how exactly this works and an example script? Thanks! -Nick
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nick wrote on 18 jul 2003 in comp.lang.javascript:
Does a background fader work by...
A) Changing the color after a long 'loop' statement???

B) Changing the color, then waiting a bit, then changing the color
again???
To me it seems B would be less cpu/browser intensive. Does anyone know
how exactly this works and an example script? Thanks! -Nick


<http://www.google.com/search?q=%22background%20fader%22%22javascript%22>

249 hits

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a
Well I found a good simple example script.

The setTimeout() function was the snip I guess I was looking for. Ive
seen many other scripts that just rely on a loop to change the colors
- the problem though - faster cpu, the faster colors change; not very
uniform. The setTimeout() fixes that. Here it is!!!

<script language="Javascript">
// 'i' increments the RGB values
// 't' changes the frequency of time
var t = "10";
function fader(i) {
var RGBstring = "rgb("+i+","+i+","+i+")";
document.bgColor = RGBstring;
setTimeout("fader("+(i-1)+")",t);
}
</script>

<FORM NAME="background">
<INPUT TYPE="button" VALUE="Start" onClick="fader(255)">
</FORM>
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.