灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:3720回复:0

星星满天闪烁的背景代码分享

楼主#
更多 发布于:2011-11-01 08:03
脚本说明:
第一步:把如下代码加入<head>区域中
<SCRIPT language=javascript1.2>
<!--
hexa = new Array(16);
for(var i = 0; i < 10; i++) hexa = 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>



喜欢0 评分0
游客

返回顶部