<strong>背景变换<br></strong><div class="htmlarea"> <textarea id="runcode61289"> <script language="JavaScript"> <!-- r=255; g=50; b=50; flag=0; t=new Array; o=new Array; d=new Array; function hex(a,c) { t[a]=Math.floor(c/16) o[a]=c%16 switch (t[a]) { case 10: t[a]='A'; break; case 11: t[a]='B'; break; case 12: t[a]='C'; break; case 13: t[a]='D'; break; case 14: t[a]='E'; break; case 15: t[a]='F'; break; default: break; } switch (o[a]) { case 10: o[a]='A'; break; case 11: o[a]='B'; break; case 12: o[a]='C'; break; case 13: o[a]='D'; break; case 14: o[a]='E'; break; case 15: o[a]='F'; break; default: break; } } function ran(a,c) { if ((Math.random()>2/3||c==0)&&c<255) { c++ d[a]=2; } else { if ((Math.random()<=1/2||c==255)&&c>0) { c-- d[a]=1; } else d[a]=0; } return c } function do_it(a,c) { if ((d[a]==2&&c<255)||c==0) { c++ d[a]=2 } else if ((d[a]==1&&c>0)||c==255) { c--; d[a]=1; } if (a==3) { if (d[1]==0&&d[2]==0&&d[3]==0) flag=1 } return c } function disco() { if (flag==0) { r=ran(1, r); g=ran(2, g); b=ran(3, b); hex(1,r) hex(2,g) hex(3,b) document.bgColor="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3] flag=50 } else { r=do_it(1, r) g=do_it(2,g) b=do_it(3,b) hex(1,r) hex(2,g) hex(3,b) document.bgColor="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3] flag-- } if (document.all) setTimeout('disco()',20) } disco() //--> </script> </textarea><br><input onclick="runEx('runcode61289')" type="button" value="运行代码"> <input onclick="doCopy('runcode61289')" type="button" value="复制代码"> <input onclick="doSave(runcode61289)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div> <br><strong>文字颜色渐变(无闪屏)</strong><br><div class="htmlarea"> <textarea id="runcode53003"> <script language="JavaScript"> <!-- //you can assign the initial color of the background here r=255; g=0; b=0; flag=0; t=new Array; o=new Array; d=new Array; function hex(a,c) { t[a]=Math.floor(c/16) o[a]=c%16 switch (t[a]) { case 10: t[a]='A'; break; case 11: t[a]='B'; break; case 12: t[a]='C'; break; case 13: t[a]='D'; break; case 14: t[a]='E'; break; case 15: t[a]='F'; break; default: break; } switch (o[a]) { case 10: o[a]='A'; break; case 11: o[a]='B'; break; case 12: o[a]='C'; break; case 13: o[a]='D'; break; case 14: o[a]='E'; break; case 15: o[a]='F'; break; default: break; } } function ran(a,c) { if ((Math.random()>2/3||c==0)&&c<255) { c++ d[a]=2; } else { if ((Math.random()<=1/2||c==255)&&c>0) { c-- d[a]=1; } else d[a]=0; } return c } function do_it(a,c) { if ((d[a]==2&&c<255)||c==0) { c++ d[a]=2 } else if ((d[a]==1&&c>0)||c==255) { c--; d[a]=1; } if (a==3) { if (d[1]==0&&d[2]==0&&d[3]==0) flag=1 } return c } function disco() { if (flag==0) { r=ran(1, r); g=ran(2, g); b=ran(3, b); hex(1,r) hex(2,g) hex(3,b) document.fgColor="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3] flag=50 } else { r=do_it(1, r) g=do_it(2,g) b=do_it(3,b) hex(1,r) hex(2,g) hex(3,b) document.fgColor="#"+t[1]+o[1]+t[2]+o[2]+t[3]+o[3] flag-- } if (document.all) setTimeout('disco()',0) } disco() //--> </script> 文字颜色渐变(无闪屏) </textarea><br><input onclick="runEx('runcode53003')" type="button" value="运行代码"> <input onclick="doCopy('runcode53003')" type="button" value="复制代码"> <input onclick="doSave(runcode53003)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div> <br><div class="htmlarea"> <textarea id="runcode30977"> <script language="javascript"> function wh_10to16(n){ var a = new Array(16); a[0]="0";a[1]="1";a[2]="2";a[3]="3";a[4]="4";a[5]="5";a[6]="6";a[7]="7";a[8]="8";a[9]="9";a[10]="A";a[11]="B";a[12]="C";a[13]="D";a[14]="E";a[15]="F"; return a[parseInt(n/16)]+a[n%16] } function wh_TransbgMakeColor(r,g,b){ return wh_10to16(r)+wh_10to16(g)+wh_10to16(b); } function wh_TransbgGetColorInc(r1,r2){ if (r1 < r2) return 1; else if (r1 > r2) return -1; else return 0; } function wh_changebg() { var r = wh_TransbgR1; var g = wh_TransbgG1; var b = wh_TransbgB1; wh_TransbgR1 += wh_TransbgGetColorInc(wh_TransbgR1,wh_TransbgR2)*wh_TransbgSpeed; wh_TransbgG1 += wh_TransbgGetColorInc(wh_TransbgG1,wh_TransbgG2)*wh_TransbgSpeed; wh_TransbgB1 += wh_TransbgGetColorInc(wh_TransbgB1,wh_TransbgB2)*wh_TransbgSpeed; if ((r-wh_TransbgR2)*(wh_TransbgR1-wh_TransbgR2) <=0 ) wh_TransbgR1 = wh_TransbgR2; if ((g-wh_TransbgG2)*(wh_TransbgG1-wh_TransbgG2) <=0 ) wh_TransbgG1 = wh_TransbgG2; if ((b-wh_TransbgB2)*(wh_TransbgB1-wh_TransbgB2) <=0 ) wh_TransbgB1 = wh_TransbgB2; document.bgColor=wh_TransbgMakeColor(wh_TransbgR1 ,wh_TransbgG1 ,wh_TransbgB1); if (wh_TransbgR1==wh_TransbgR2 && wh_TransbgG1==wh_TransbgG2 && wh_TransbgB1==wh_TransbgB2){ if ((++wh_TransbgIndex) >= wh_TransbgTotal-1) { if (!wh_TransbgLoop && wh_TransbgCount==1) return; wh_TransbgCount++; wh_TransbgIndex=0; } wh_TransbgR1 =wh_TransbgColorsR[wh_TransbgIndex]; wh_TransbgG1 =wh_TransbgColorsG[wh_TransbgIndex]; wh_TransbgB1 =wh_TransbgColorsB[wh_TransbgIndex]; wh_TransbgR2 =wh_TransbgColorsR[wh_TransbgIndex+1]; wh_TransbgG2 =wh_TransbgColorsG[wh_TransbgIndex+1]; wh_TransbgB2 =wh_TransbgColorsB[wh_TransbgIndex+1]; } setTimeout("wh_changebg()", 1); } wh_TransbgR1=0; wh_TransbgG1=0; wh_TransbgB1=0; wh_TransbgR2=0; wh_TransbgG2=0; wh_TransbgB2=0; wh_TransbgSpeed=1; wh_TransbgLoop=true; wh_TransbgTotal=4; wh_TransbgIndex =wh_TransbgTotal-1; wh_TransbgColorsR = new Array(wh_TransbgTotal); wh_TransbgColorsG = new Array(wh_TransbgTotal); wh_TransbgColorsB = new Array(wh_TransbgTotal); wh_TransbgColorsR[0]=255; wh_TransbgColorsG[0]=240; wh_TransbgColorsB[0]=230; wh_TransbgColorsR[1]=230; wh_TransbgColorsG[1]=255; wh_TransbgColorsB[1]=240; wh_TransbgColorsR[2]=240; wh_TransbgColorsG[2]=230; wh_TransbgColorsB[2]=255; wh_TransbgColorsR[3]=255; wh_TransbgColorsG[3]=240; wh_TransbgColorsB[3]=230; wh_TransbgCount=0; wh_changebg(); </script> </textarea><br><input onclick="runEx('runcode30977')" type="button" value="运行代码"> <input onclick="doCopy('runcode30977')" type="button" value="复制代码"> <input onclick="doSave(runcode30977)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div> <br>