發新話題
打印

變色捲軸

變色捲軸

滾動捲軸時 scrollbar 會變色


<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>


我唔係人.........

TOP

複製上列語法



我唔係人.........

TOP