Hallo Leute,
ich habe ein Javascript gefunden, um die Hintergrundfarbe durchwechseln zu lassen. Allerdings gehen hier nur 3 Farben, wobei die Anfangs- und die Endfarbe gleich sein müssen, damit es ein durchgehender Effekt wird. Ich benötige aber mindestens 4 Farben, besser sogar 6. Wie muss das Script abgeändert werden, damit ich den 6-Farben Effekt hin bekomme?
<html>
<head><script LANGUAGE="JavaScript">
<!--
// Delux Color Fading Script v1.0
//
// written by Michael Locher
// Copyright 1998 by Michael Locher
//
// email: michael.locher@earthling.net
//
// You can use this script for free if copyright info is intact.
// It would be nice if you drop me a note when using this script
// on your homepage.
//
// Please report bugs to michael.locher@earthling.net
//
// 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 = infinite
var step = 8; //sets the step for de- or increasing the color value which actually changes the speed
var 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>
<title>JavaFILE</title>
<base target="leftframe">
</head>
<body BGCOLOR="#ffffff" link="#CC0033" vlink="#333399" alink="#FF0000"
onLoad="fadestart();">
<!--content start-->
<p align="center"><img src="http://www.javafile.com/images/banner.GIF"
alt="banner.GIF (2826 bytes)"></p>
<table WIDTH="96%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
<tr>
<td WIDTH="100%"><font FACE="ARIEL,HELVETICA" SIZE="-1"><p align="center">One time or
infinite loops are possible.<br>
The script can be stopped and restarted by the user.<br>
For setup information take a look at the source code<br>
<br>
</font><a href="http://www.javafile.com/javascripts/browsers/fader.zip"><font size="3">Download
the Script</font></a><font FACE="ARIEL,HELVETICA" SIZE="-1"><br>
</p>
<div align="center"><center><address>
© 1998 by <a HREF="mailto:michael.locher@earthling.net">Michael Locher</a> <br>
<br>
<font SIZE="1"><a href="javascript:fadestop();">Stop color fading</a>
<a href="javascript:faderestart();">Restart color fading</a> </font></font>
</address>
</center></div></td>
</tr>
</table>
<!--content stop-->
</body>
</html>