页面上出现满天的星星,效果非常好看的 - 中国WEB开发者网络 (http://www.webasp.net) -- 网页特效 (http://www.webasp.net/javascript/) --- 页面上出现满天的星星,效果非常好看的 (http://www.webasp.net/javascript/1/649.htm) |
| -- 发布日期: 2005-06-24 |
| <!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! --> <!-- 要实现此效果需要 3 个步骤: --> <!-- 第 1 步: --> <!-- 把下面的代码加到<HEAD></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> <!-- 第 2 步: --> <!-- 把<BODY>中的属性代码改为: --> <BODY aLink=#ffffff bgColor=#ffffff link=#ffffff onload=start_it()> <!-- 第 3 步: --> <!-- 把下面的代码加到<BODY></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=\"../images/649/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> |
| webasp.net |