»
EnglishFrenchVietnamese

Print - Delux Color Fading Script - JavaScriptBank.com

Full version: jsB@nk » Background » Delux Color Fading Script
URL: https://www.javascriptbank.com/delux-color-fading-script.html

Delux Color Fading Script © JavaScriptBank.comThis JavaScript makes background color(yellow) change to bright/dark continually.

Full version: jsB@nk » Background » Delux Color Fading Script
URL: https://www.javascriptbank.com/delux-color-fading-script.html



JavaScript
<script language="javascript">/*     This script downloaded from www.JavaScriptBank.com     Come to view and download over 2000+ free javascript at www.JavaScriptBank.com*/<!--/*     This script downloaded from www.JavaScriptBank.com     Come to view and download over 2000+ free javascript at www.JavaScriptBank.com*/// Delux Color Fading Script v1.0// Setupinformations://// Copy and past the script in the header of your HTML document// and change the changeable variables below.// It's importent that you add ////      onLoad="javascript:fadestart();"//// to the BODY tag of your HTML document like on the BODY tag below.// Unless the script won't start.//// to allow the user to stop and restart the color fading just insert// the following HTML code somewhere in the body of your document////      <A href="javascript:fadestop();">Stop color fading</A>////      <A href="javascript:faderestart();">Restart color fading</A>//// that may be useful when using infinite loop because the script needs// a lot of resources and may slow down the computer// Changeable variables:var loop = 1;                               //0 = one time, 1 = infinitevar step = 8;                               //sets the step for de- or increasing the color value which actually changes the speedvar startcolor = new Array(255,128,0);      //start color as a RGB value (0-255)var middlecolor = new Array(255,255,0);     //middle color as a RGB value (0-255)var endcolor = new Array(255,128,0);        //end color as a RGB value (0-255) // equate the middle with end values if you do not want to use a middle color// if you use infinite loops start and end color should be the same values// DO NOT CHANGE ANYTHING BELOW HERE !!!!// (Unless you know what you do) var stopped = 0;var factor = new Array(1,1,1);var firstfactor = new Array(1,1,1);var secondfactor = new Array(1,1,1);var color = new Array(startcolor[0],startcolor[1],startcolor[2]);var nextcolor = new Array(middlecolor[0],middlecolor[1],middlecolor[2]);var hex = new Array;var letters = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');function fadestart() {for (i=0 ; i <=2 ; i++) { if (middlecolor[i] > startcolor[i]) {firstfactor[i] = -1;}if (middlecolor[i] == startcolor[i]) {firstfactor[i] = 0;}if (endcolor[i] > middlecolor[i]) {secondfactor[i] = -1;}if (endcolor[i] == middlecolor[i]) {secondfactor[i] = 0;}  factor[i] = firstfactor[i];}fadeing = setTimeout('fade()',1);}function fadestop(){stopped = 1;clearTimeout(fadeing)}function faderestart(){if (stopped == 1){fadeing = setTimeout('fade()',1);}}function fade() {for (i=0 ; i<=2 ; i++) {firstletter = Math.floor(eval(color[i] / 16));secondletter = eval(color[i] -(firstletter * 16));hex[i] = letters[firstletter]+letters[secondletter];color[i] = color[i] - (factor[i] * step);if (((color[i]*factor[i])-(nextcolor[i]*factor[i])) <= 0) {factor[i] = 0;color[i] = nextcolor[i];}}document.bgColor = '#'+hex[0]+hex[1]+hex[2];if (((Math.abs(factor[0]) + Math.abs(factor[1]) + Math.abs(factor[2])) == 0)&&((color[1] != endcolor[1])||(color[2] != endcolor[2])||(color[0] != endcolor[0]))){for (i=0 ; i<=2 ; i++) {nextcolor[i]=endcolor[i];factor[i]=secondfactor[i];}}if ( (Math.abs(factor[0]) + Math.abs(factor[1]) + Math.abs(factor[2])) != 0 ){fadeing = setTimeout('fade()',1);}else {if (loop == 1){for (i=0 ; i<=2 ; i++) {factor[i]=firstfactor[i];color[i]=startcolor[i];nextcolor[i]=middlecolor[i];}fadeing = setTimeout('fade()',1);}}}//--></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<BODY bgColor=#ff8000 onload=javascrip:fadestart();></BODY><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->