< html < head < title bgcolor< /title < meta http-equiv="Content-Type" content="text/html; charset=gb2312" < 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==0&&d==0&&d==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+o+t+o+t+o 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+o+t+o+t+o flag-- } if (document.all) setTimeout('disco()',0) } //-- < /script < /head
碰到一个用javascript实现随机跳转页面实例,发布出来,共同研究下,或许有用哦。 请看下面的实例 html head titlePlease waiting.../title script language="javascript" !-- function urlList(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) { this[0]=a; this[1]=b; thi...