笨笨網站超級論壇 (綠色版本)


頁: [1]

#1  變色捲軸 -  (Administrator) 發表於 27-5-2013 10:49

滾動捲軸時 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>


#2  複製上列語法 -  (Administrator) 發表於 27-5-2013 10:52

<form name="copy">
<textarea cols="40" name="txt" rows="4" style="BACKGROUND-COLOR:#ffffff; COLOR:#000000; FONT-SIZE:9pt">
<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>
</textarea><br>
<input onclick="javascript:this.form.txt.focus();this.form.txt.select();" type="button" value="全選">
</form>

<br>

<script type="text/javascript"><!--
google_ad_client = "ca-pub-4078143172638881";
/* 336X280 */
google_ad_slot = "3268225205";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
頁: [1]

Powered by Discuz Simply! 0.54 Released © wxyuan90