130、星星满天闪烁

130、星星满天闪烁

脚本说明:

第一步:把如下代码加入<head>区域中

<SCRIPT language=javascript1.2>

<!--

hexa = new Array(16);

for(var i = 0; i < 10; i++) hexa[i] = i;

hexa[10]="a";

hexa[11]="b";

hexa[12]="c";

hexa[13]="d";

hexa[14]="e";

hexa[15]="f";

function hex(i)

{

if (i < 0) return "00";

else if (i > 255) return "ff";

else return "" + hexa[Math.floor(i/16)] + hexa[i%16];

}

function setbgColor(r, g, b)

{

var hr = hex(r);

var hg = hex(g);

var hb = hex(b);

document.bgColor = "#"+hr+hg+hb;

}

function fade(sr, sg, sb, er, eg, eb, step)

{

for(var i = 0; i <= step; i++)

{

setbgColor( Math.floor(sr * ((step-i)/step) + er * (i/step)),

Math.floor(sg * ((step-i)/step) + eg * (i/step)), Math.floor(sb *

((step-i)/step) + eb * (i/step)));

}

}

 

 

//-->

</SCRIPT>

 

 

第二步:把如下代码加入<body>区域中

<SCRIPT language=javascript1.2>

<!--

for(i=1;i<=10;i++)

{

document.write("<div id=\"star"+i+"\" style=\"position:absolute;top:80%;left:"+(Math.floor(Math.random()*5)+9*(i-1))+"%;width:21;height:21;visibility:hidden;\"><dd><img src=\"star.gif\" WIDTH=\"21\" HEIGHT=\"21\"></dd></div>");

}    

function randommove()

{    

       for(i=1;i<=10;i++)

       eval("star"+i+".style.top=get_top()");

      

}           

 

function get_top()

{

var t,t2;

t=Math.floor(Math.random()*380);

t2=t.toString()+"px";

return(t2);

}

function set_visible()

{

       for(i=1;i<=10;i++)

       eval("star"+i+".style.visibility=\"visible\"");

       banner.style.visibility="visible";

       friends.style.visibility="visible";

       high(pic);

             

}

function bar_show()

{     bar.style.visibility="visible";

}

function start_it()

{

fade(255,255,255, 0,0,0, 50);

setInterval("randommove()",1000);

set_visible();

setTimeout("bar_show()",2000);

}

function end_it()

{

banner.style.visibility="hidden";

friends.style.visibility="hidden";

pic.style.visibility="hidden";

fade(0,0,0,255,255,255,10);

}

-->

</SCRIPT>

 

第三步:<body>改为

<BODY aLink=#ffffff bgColor=#ffffff link=#ffffff onload=start_it()

onunload=end_it() text=#ffffff topMargin=0 vLink=#ffffff>

Write a comment

Comments: 0