[Fader II]





Text Box

Free JavaScripts provided by
The Nightfire Webworker Archiv

Verschiedene Anwendungsmöglichkeiten, einen Fading Effekt einzusetzen...

Hinweis: Das Faden des Seitenhintergrundes funktioniert nicht, wenn ein Hintergrundbild eingesetzt wird.

[Code]

[zwischen <HEAD> und </HEAD>]

<script type="text/javascript">
<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://www.nightfire.ch/java/
Created by: Tony Tschopp :: http://www.goodturnwebdesign.com */

/* comp = name (ID="comp") of the HTML page component to fade
cbeg = start value for color in #rrggbb format
cend = end value for color in #rrggbb format
iter = number of steps in the fade from start color to end color
time = number of milliseconds to display each step
rbeg = start value for red component of rbg color
gbeg = start value for green component of rbg color
bbeg = start value for blue component of rbg color
rend = end value for red component of rbg color
gend = end value for green component of rbg color
bend = end value for blue component of rbg color */


var hstr = '#';
var hdig = "0123456789abcdef";
function mOvr(comp, cbeg, cend, iter, time) {
var rbeg = hdig.indexOf(cbeg.substr(1,1))*16 + hdig.indexOf(cbeg.substr(2,1));
var gbeg = hdig.indexOf(cbeg.substr(3,1))*16 + hdig.indexOf(cbeg.substr(4,1));
var bbeg = hdig.indexOf(cbeg.substr(5,1))*16 + hdig.indexOf(cbeg.substr(6,1));
var rend = hdig.indexOf(cend.substr(1,1))*16 + hdig.indexOf(cend.substr(2,1));
var gend = hdig.indexOf(cend.substr(3,1))*16 + hdig.indexOf(cend.substr(4,1));
var bend = hdig.indexOf(cend.substr(5,1))*16 + hdig.indexOf(cend.substr(6,1));
for ( i = 1, r = rbeg, g = gbeg, b = bbeg;
i <= iter;
r = Math.round(rbeg + i * ((rend - rbeg) / (iter-1))),
g = Math.round(gbeg + i * ((gend - gbeg) / (iter-1))),
b = Math.round(bbeg + i * ((bend - bbeg) / (iter-1))), i++ ) {
hstr = '#' + hdig.charAt(Math.floor(r/16)) + hdig.charAt(r%16) +
hdig.charAt(Math.floor(g/16)) + hdig.charAt(g%16) +
hdig.charAt(Math.floor(b/16)) + hdig.charAt(b%16);
setTimeout('var el = document.getElementById("' + comp + '"); el.style.backgroundColor = "' + hstr + '";', i * time);
}
}

function mOut(comp, cbeg, cend, iter, time) {
var rbeg = hdig.indexOf(cbeg.substr(1,1))*16 + hdig.indexOf(cbeg.substr(2,1));
var gbeg = hdig.indexOf(cbeg.substr(3,1))*16 + hdig.indexOf(cbeg.substr(4,1));
var bbeg = hdig.indexOf(cbeg.substr(5,1))*16 + hdig.indexOf(cbeg.substr(6,1));
var rend = hdig.indexOf(cend.substr(1,1))*16 + hdig.indexOf(cend.substr(2,1));
var gend = hdig.indexOf(cend.substr(3,1))*16 + hdig.indexOf(cend.substr(4,1));
var bend = hdig.indexOf(cend.substr(5,1))*16 + hdig.indexOf(cend.substr(6,1));
for ( i = 1, r = rend, g = gend, b = bend;
i <= iter;
r = Math.round(rend - i * ((rend - rbeg) / (iter-1))),
g = Math.round(gend - i * ((gend - gbeg) / (iter-1))),
b = Math.round(bend - i * ((bend - bbeg) / (iter-1))), i++ ) {
hstr = '#' + hdig.charAt(Math.floor(r/16)) + hdig.charAt(r%16) +
hdig.charAt(Math.floor(g/16)) + hdig.charAt(g%16) +
hdig.charAt(Math.floor(b/16)) + hdig.charAt(b%16);
setTimeout('var el = document.getElementById("' + comp + '"); el.style.backgroundColor = "' + hstr + '";', i * time);
}
}
// End -->
</script>

[IN den <BODY> Tag]

id="content"

[zwischen <BODY> und </BODY>]

<form id="myForm" name="myForm" style="border: 3px dashed blue; width: 250px">
<div align="center">
<br>
<input type=button id="button1" style="background: #cc9933"
value="Fade this button"
onMouseOver="mOvr('button1','#cc9933','#6699cc',10,100)"
onMouseOut="mOut('button1','#cc9933','#6699cc',10,100)"
onMouseDown="document.myForm.button1.value='Thank You!'">
<br>
<input type=button id="button2" value="Fade the text box"
onMouseOver="mOvr('myText','#996633','#cccc99',10,40)"
onMouseOut="mOut('myText','#996633','#cccc99',10,40)"
onMouseDown="document.myForm.button2.value='Gracias!'">
<br>
<input type=button id="button3" value="Fade this page"
onMouseOver="mOvr('myPage','#ffffff','#758642',10,100)"
onMouseOut="mOut('myPage','#ffffff','#758642',10,100)"
onMouseDown="document.myForm.button3.value='Merci!'">
<br>
</div>
</form>

<div align="center" id="myText" style="border: 3px solid #c0c0c0; display: block; width: 250; background-color: #996633; padding: 4px;">
Text Box<br><br>Free JavaScripts provided by<br>
The Nightfire Webworker Archiv
</div>

[Autor]

Tony Tschopp

[Download]

Kopieren Sie bitte den Code

Copyright © 1998- Nightfire Webworker Archiv Script No: 650