Home / Free JavaScripts / Special Effects With Background / Here

Cut & Paste Fade-in-Fade-out background
Credit: Dave Methvin, Windows Magazine

Description: Creates a beautiful fading of color, from black to white, in this case, as someone enters the page.

Example: You just saw it! If not, reload this page to see it again.

Directions: Simply cut and paste the script into the <HEAD> section of your webpage. You may increase the speed of the fading by changing 50 to a lesser positive number (ie: 20). You may change the fade-from and fade-to color by entering new hex values for the two colors, the (00,00,00) being the fade-from color, the others being the fade-to color. Click here to see a chart if you are unfamiliar with hex values of colors

<SCRIPT>
<!--
/*Background fade by Dave Methvin,
Windows Magazine
May be used/modified if credit line is
retained*/
function BgFade(red1, grn1, blu1, red2,
grn2, blu2, steps) {
sred = red1; sgrn = grn1; sblu = blu1;
ered = red2; egrn = grn2; eblu = blu2;
inc = steps;
step = 0;
RunFader();
}
function RunFader() {
var epct = step/inc;
var spct = 1 - epct;
document.bgColor =
Math.floor(sred * spct + ered *
epct)*256*256 +
Math.floor(sgrn * spct + egrn * epct)*256 +
Math.floor(sblu * spct + eblu * epct);
if ( step < inc ) {
setTimeout('RunFader()',
50);
}
step++;
}
BgFade(0x
00,0x00,0x00, 0xFF,0xFF,0xFF,10);
//-->
</SCRIPT>

[an error occurred while processing this directive]

Copyright © 1997-2014 JavaScript Kit. NO PART may be reproduced without author's permission.