✔ 最佳答案
<script language="JavaScript">
var scrollPct, prevStep, nextStep, interStep
steps = new Array();
steps[0] = new Array(255,0,0);
steps[1] = new Array(255,128,0);
steps[2] = new Array(255,255,0);
steps[3] = new Array(0,255,0);
steps[4] = new Array(0,0,255);
steps[5] = new Array(128,0,255);
steps[6] = new Array(255,0,255);
function newColor(chan) {
var i=Math.floor(steps[prevStep][chan]+interStep*(steps[nextStep][chan]-steps[prevStep][chan]));
return i;
}
function scrollFunk() {
scrollPct=(steps.length-1)*document.body.scrollTop/(document.body.scrollHeight-document.body.clientHeight);
prevStep=Math.floor(scrollPct);
nextStep=Math.ceil(scrollPct);
interStep=scrollPct-prevStep;
var newRGB="rgb("+newColor(0)+","+newColor(1)+","+newColor(2)+")";
var invRGB="rgb("+(255-newColor(0))+","+(255-newColor(1))+","+(255-newColor(2))+")";
if (document.body.style.scrollbarTrackColor != null) {
document.body.style.scrollbarFaceColor=newRGB;
document.body.style.scrollbarTrackColor=invRGB;
}
}
window.onscroll=scrollFunk;
</script>
2008-06-01 03:35:13 補充:
steps[6] = new Array(255,0,255);
如果你想整多D色就加多幾個item la..
new Array(R,G,B);
HTML既RGB碼,,但係是10進制,不是16進制,,
姐係 0 to 255, 無ABCDEF