本帖最后由 renrousousuo 于 2009-01-18 19:00:37 编辑

解决方案 »

  1.   

    奥运五环
    <html>
    <head><title>贺岁礼花●五环--2009清洁工版</title></head>
    <body style="overflow:hidden;background-color:Black;">
    </body>
    <script type="text/javascript">
    function hsl2color(hsl) {
    if (hsl.h > 360 || hsl.h < 0 || hsl.s > 100 || hsl.s < 0 || hsl.l > 100 || hsl.l < 0)
    return "#000000";
    var rgb = {r: 0, g: 0, b: 0};
    if (hsl.h <= 60) {
    rgb.r = 255;
    rgb.g = Math.floor(255 / 60 * hsl.h);
    } else if (hsl.h <= 120) {
    rgb.r = Math.floor(255 - (255 / 60) * (hsl.h - 60));
    rgb.g = 255;
    } else if (hsl.h <= 180) {
    rgb.g = 255;
    rgb.b = Math.floor((255 / 60) * (hsl.h - 120));
    } else if (hsl.h <= 240) {
    rgb.g = Math.floor(255 - (255 / 60) * (hsl.h - 180));
    rgb.b = 255;
    } else if (hsl.h <= 300) {
    rgb.r = Math.floor((255 / 60) * (hsl.h - 240));
    rgb.b = 255;
    } else if (hsl.h <= 360) {
    rgb.r = 255;
    rgb.b = Math.floor(255 - (255 / 60) * (hsl.h - 300));
    }
    var sat = Math.abs((hsl.s - 100) / 100);
    rgb.r = Math.floor(rgb.r - (rgb.r - 128) * sat);
    rgb.g = Math.floor(rgb.g - (rgb.g - 128) * sat);
    rgb.b = Math.floor(rgb.b - (rgb.b - 128) * sat);
    var lum = (hsl.l - 50) / 50;
    if (lum > 0) {
    rgb.r = Math.floor(rgb.r + (255 - rgb.r) * lum);
    rgb.g = Math.floor(rgb.g + (255 - rgb.g) * lum);
    rgb.b = Math.floor(rgb.b + (255 - rgb.b) * lum);
    } else if (lum < 0) {
    rgb.r = Math.floor(rgb.r + rgb.r * lum);
    rgb.g = Math.floor(rgb.g + rgb.g * lum);
    rgb.b = Math.floor(rgb.b + rgb.b * lum);
    }
    return "#" + ("00000" + (rgb.r * 256 * 256 + rgb.g * 256 + rgb.b).toString(16)).replace(/^.*(.{6}$)/g, "$1");
    }function Ball(parent, text) {
    this.parent = parent;
    this.text = text;
    this.visible = true;
    this.span = document.createElement("span");
    this.span.innerHTML = this.text;
    this.span.style.position = "absolute";
    }Ball.prototype.update = function(color, x, y, size, alpha, speed, fire) {
    this.fire = fire;
    this.alpha = alpha;
    this.speed = speed;
    this.gravity = 0;
    this.x = x;
    this.y = y;
    this.color = color;
    this.hsl = {h: color, s: 100, l: 80};
    this.size = size;
    this.doChange();
    }Ball.prototype.doChange = function() {
    with (this.span.style) {
    fontSize = this.size + "px";
    left = this.x + "px";
    top = this.y + "px";
    color = hsl2color(this.hsl);
    }
    if (!this.span.parent) this.parent.insertBefore(this.span, this.parent.firstChild);
    }Ball.prototype.move = function() {
    this.x = Math.cos(this.alpha) * this.speed + this.x;
    this.y = Math.sin(this.alpha) * this.speed + this.y;
    this.y = this.gravity + this.y;
    this.gravity += 0.05;
    this.hsl.l -= this.fire;
    this.doChange();
    }Ball.prototype.hide = function() {
    if (!this.visible) return;
    this.visible = false;
    this.span.style.display = "none";
    }Ball.prototype.show = function() {
    if (this.visible) return;
    this.visible = true;
    this.span.style.display = "block";
    }function Firework(parent, text, size, count, speed) {
    this.parent = parent;
    this.speed = speed;
    this.size = size;
    this.total = 0;
    this.active = false;
    this.balls = new Array(count);
    for (var i = 0; i < this.balls.length; i++) {
    this.balls[i] = new Ball(parent, text);
    this.balls[i].firework = this;
    this.balls[i].index = i;
    this.balls[i].hide();
    }
    }Firework.prototype.tick = function() {
    if (!this.active) return;
    if (typeof this.ontick == "function") this.ontick(this);
    for (var i = 0; i < this.balls.length; i++) {
    if (!this.balls[i].visible) continue;
    if (typeof this.onballmove == "function")
    this.onballmove(this.balls[i]);
    else this.balls[i].move();
    }
    var self = this;
    this.timer = setTimeout(function() { self.tick(); }, 5);
    }Firework.prototype.replay = function() {
    this.active = true;
    this.tick();
    if (typeof this.onreplay == "function") this.onreplay(this);
    }var firework = new Firework(document.body, "●", 12, 105, 0);
    firework.ontick = function () {
    if (this.total % 80 == 0) {
    var h = document.body.clientHeight || document.documentElement.clientHeight;
    var w = document.body.clientWidth || document.documentElement.clientWidth;
    for (var i = 0; i < 5; i++) {
    var color;
    var speed = 9.3;
    var alpha = Math.PI * 1.5;
    switch (i) {
    case 0: color = 240; speed = 12.7; alpha -= 0.43; break; // 蓝色 
    case 1: color = 30; alpha -= 0.27; break; // 黄色
    case 2: speed = 11.5; break; // 黑色
    case 3: color = 120; alpha += 0.27; break; // 绿色
    case 4: color = 0; speed = 12.7; alpha += 0.43; break; // 红色
    }
    this.balls[i].update(color, w / 2, h, 32, alpha, speed, 0.5);
    this.balls[i].hsl.l = 50;
    if (i == 2) {
    this.balls[i].hsl.h = 0;
    this.balls[i].hsl.s = 0;
    }
    this.balls[i].show();
    }
    }
    if (this.total % 80 == 45) {
    var count = 5;
    for (var i = 0; i < 5; i++) {
    this.balls[i].hide();
    for (var j = 0; j < 20; j++) {
    this.balls[count].update(this.balls[i].color, this.balls[i].x, this.balls[i].y, 
    24, j / 20 * 2 * Math.PI, 7, 3.9);
    if (i == 2) {
    this.balls[count].hsl.h = 0;
    this.balls[count].hsl.s = 0;
    }
    this.balls[count].show();
    count++;
    }
    }
    }
    this.total++;
    }
    firework.total = 0;
    firework.replay();
    </script>
    </html>
      

  2.   

    呵呵,lz的想象力也很丰富.太麻烦,别帮我改了,以免耽误您时间创作.还不到最后完全版,请直接录入.5400字约
    <HTML><HEAD><META http-equiv='Content-Type' content='text/html;charset=utf8'>
    <TITLE>狂舞风云,2009</TITLE>
    <STYLE>font{position:absolute;z-index:10}</STYLE>
    </HEAD><BODY bgcolor="black" text="white" style="overflow:hidden;">
    <div id="a" style="width:100%;height:100%;background-color:black";></div>
    <script>
     //原作:风云舞 博客:http://blog.sina.com.cn/shenmoduijue
    var xall=screen.availWidth,yall=screen.availHeight-180,$=Math.random
    function gcor(){return ($()*4096).toString(16)}
    onload=function(){var i=0;while(i++<8)p.add();
    for(i=0;i++<35;)setTimeout("xin.add()",i*120)
    setInterval("xinx=$()*xall,xinsize=6+($()*25)",5000)
    }
    var xinx=$()*xall,xinsize=6+($()*25)
    var xin={
    add:function(){
    var d=document.createElement("font")
    d.color=gcor();d.dx=xinsize;d.dx2=5;d.max=10;with(d.style){fontSize=xinsize;left=xinx;top=yall;}
    d.innerText="·";d.go=setInterval(function(){xin.go(d)},40);a.appendChild(d);
    },
    go:function(obj){
    var x=obj.offsetLeft,y=obj.offsetTop,dx=obj.dx,dx2=obj.dx2,max=obj.max
    max%2==0?dx2+=1:dx2-=1;obj.dx2=dx2
    if(dx2==-max||dx2==max)obj.max=obj.max+3
    obj.style.top=y-(dx/5);obj.style.left=x+dx2
    if(y<yall-(dx*25)){clearInterval(obj.go);a.removeChild(obj);xin.add();}
    }}var p={
    add:function(){
    var size1=6+($()*25),x=$()*xall
    var d=document.createElement("font"),ad=Math.ceil($()*4),t="●"
    d.color=gcor();d.dx=size1;with(d.style){fontSize=size1;left=x;top=yall;}
    if(ad==2){t="★"}else if(ad==3){t="*"}else if(ad==4){t="·"};
    d.innerText=t;d.ad=ad;d.go=setInterval(function(){p.go(d)},30);a.appendChild(d)
    },
    go:function(obj){
    var y=obj.offsetTop,dx=obj.dx;obj.style.top=y-(dx/5)
    if(y<yall-(dx*15))return p.bao(obj)
    },
    bao:function(obj){
    var x=obj.offsetLeft,y=obj.offsetTop,ad=obj.ad,s=parseInt(obj.style.fontSize),c=obj.color
    clearInterval(obj.go);
    if(ad!=3){a.removeChild(obj);p.add()}
    if(ad==1){for(var i=0;i<($()*12)+6;i++){flash1.add(x,y,s-5,c)}}
    else if(ad==2){for(var i=0;i<($()*10)+15;i++){flash2.add(x,y,i+10,s-5)}}
    else if(ad==3){
    var sz=parseInt(obj.style.fontSize)
    obj.face="楷体_GB2312";obj.jia=0;obj.innerText="恭\n喜"
    obj.style.fontSize=sz*3;obj.style.left=obj.offsetLeft-(sz*2);obj.style.top=obj.offsetTop-(sz*2);
    clearInterval(obj.go);obj.go=setInterval(function(){p.flash3_go2(obj)},30);
    var i=0;while(i++<5){setTimeout(function(){flash3.add(x,parseInt(obj.style.fontSize)/3)},i*350)}
    }else if(ad==4){flash4.add(x,y,s,c)}
    },
    flash3_go2:function(obj){
    var c=obj.color,r=c.substr(1,2),g=c.substr(3,2),b=c.substr(5,2),dx=3,jia=obj.jia
    r=Math.floor(("0x"+r).toString(10));g=Math.floor(("0x"+g).toString(10));b=Math.floor(("0x"+b).toString(10));
    if(jia==0){r+=dx;g+=dx;b+=dx;obj.color="rgb("+r+","+g+","+b+")"}
    else if(jia==30){r-=dx;g-=dx;b-=dx;obj.color="rgb("+r+","+g+","+b+")"}
    else{obj.color=gcor();jia++;obj.jia=jia;if(jia==30)obj.innerText="发\n财"}
    if(r>255||g>255||b>255){obj.jia=1;obj.innerText="牛\n年"}
    if(r+g+b<0){clearInterval(obj.go);a.removeChild(obj);p.add()}
    }}  //endvar flash1={
    add:function(x,y,size1,color1){
    var dx=Math.round($()*50)-25,dy=Math.round($()*50)-25
    if(Math.abs(dx)<2)dx=5;if(Math.abs(dy)<2)dy=-5;
    var d=document.createElement("font");
    with(d.style){fontSize=size1;left=x;top=y;}
    d.color=color1;d.oldx=x;d.oldy=y;d.dx=dx;d.dy=dy;
    d.innerText="●";d.go=setInterval(function(){flash1.go(d)},30);a.appendChild(d)
    },
    go:function(obj){
    var x=obj.oldx,y=obj.oldy,x2=obj.offsetLeft,y2=obj.offsetTop
    if(Math.abs(x-x2)<150&&Math.abs(y-y2)<150){obj.style.left=x2+Math.floor(obj.dx);obj.style.top=y2+Math.floor(obj.dy);}else{clearInterval(obj.go);a.removeChild(obj);}
    }}  //endvar flash2={
    add:function(x,y,pos,size1){
    var d=document.createElement("font");
    with(d.style){fontSize=size1;left=x;top=y;}
    d.color=gcor();d.oldx=x;d.oldy=y;d.pos=pos;d.innerText="★";
    d.go=setInterval(function(){flash2.go(d)},30);a.appendChild(d)
    },
    go:function(obj){
    var x=obj.oldx,y=obj.oldy,x2=obj.offsetLeft,y2=obj.offsetTop,p=obj.pos;
    if(Math.abs(x-x2)<125&&Math.abs(y-y2)<125){obj.style.left=x2+(p*Math.cos(p));obj.style.top=y2+(p*Math.sin(p));}else{clearInterval(obj.go);a.removeChild(obj);}
    }}  //endvar flash3={
    add:function(x,size1){
    var arr=[],size2=parseFloat(size1)+2,x2=Math.round($()*100)-50+x,d=document.createElement("div");
    with(d.style){position="absolute";zIndex=5;left=x2;top=yall;}
    for(var i=0;i++<5;){var os=size2-(i*2);if(os<=0)os=1;arr[i]="<font color='"+gcor()+"' style='font-size:"+os+"'>*</font><br>"}
    d.innerHTML=arr.join("");d.go=setInterval(function(){flash3.go(d)},30);a.appendChild(d);
    },
    go:function(obj){
    var top1=obj.offsetTop;obj.style.top=top1-30;if(top1<-50){clearInterval(obj.go);a.removeChild(obj)}
    }}  //endvar flash4={
    add:function(x,y,size1,color1){
    var arr=[],d=document.createElement("div");d.ci=1;
    with(d.style){position="absolute";left=x;top=y;fontSize=size1;color=color1;}
    for(var i=0;i++<($()*60)+40;){
    var gx=parseFloat(size1)*12,sx=Math.ceil($()*gx)-(gx/2),sy=Math.ceil($()*gx)-(gx/2);
    arr[i]="<font color='"+color1+"' style='left:"+sx+";top:"+sy+"'>.</font>"
    }
    d.innerHTML=arr.join("");d.go=setInterval(function(){flash4.go(d)},70);a.appendChild(d);
    },
    go:function(obj){
    var ci=obj.ci;ci++;if(ci==35){clearInterval(obj.go);return a.removeChild(obj)}obj.ci=ci;
    if((ci/2).toString().indexOf(".")==-1){obj.style.visibility="visible"}else{obj.style.visibility="hidden"}
    }}  //end
    </script></BODY></HTML>
      

  3.   

    <html>
    <head><title>ialvin.cn</title>
    <style>
    body{ background:#000; padding:0; margin:0; overflow:hidden; }
    .ptr{ width:2px; height:2px; overflow:hidden; position: absolute; }
    </style>
    <script>
    var winHeight;
    function mouseX(event) { event=event||window.event; return (event.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft))||event.pageY; }
    function mouseY(event) { event=event||window.event; return (event.clientY+(document.documentElement.scrollTop||document.body.scrollTop))||event.pageY; }
    function getWindowHeight() { return window.innerHeight || document.body.clientHeight; }
    window.onload = function(e) { winHeight = getWindowHeight(); };function setColor(p) {
    p.r=parseInt(p.r/2); p.g=parseInt(p.g/2); p.b=parseInt(p.b/2);
    if (p.r==0 && p.g==0 && p.b==0) return document.body.removeChild(p.ptr);
    p.ptr.style.background = "rgb("+p.r+","+p.g+","+p.b+")";
    setTimeout(function(){setColor(p);}, 150);
    }
    function Point(x, y, r, g, b) {
    this.ptr = document.createElement("DIV");
    this.ptr.className = "ptr";
    document.body.appendChild(this.ptr);
    this.ptr.style.left = x + "px";
    this.ptr.style.top  = y + "px";
    this.r = 2*r;
    this.g = 2*g;
    this.b = 2*b;
    var p = this;
    setTimeout(function(){setColor(p)}, Math.random()*200);
    }
    function Fireworks(mx, my) {
    this.mx = mx;
    this.my = my;
    this.cx = mx;
    this.cy = winHeight;
    }
    Fireworks.prototype.run = function() {
    if (this.cy <= this.my) return this.flash();
    new Point(this.cx, this.cy, 0x40, 0x40, 0x40);
    this.cy -= 10;
    var self = this;
    setTimeout( function(){self.run();}, 50);
    };
    Fireworks.prototype.init = function() {
    this.fs = [];
    var r1 = 128+Math.random()*128;
    var g1 = 128+Math.random()*128;
    var b1 = 128+Math.random()*128;
    for (var i=0; i<20; i++) {
    var o = {r:r1,g:g1,b:b1};
    var d = Math.random() * 2 * Math.PI;
    var d1 = Math.random();
    o.vx = Math.sin(d) * d1 * 8;
    o.vy = Math.cos(d) * d1 * 8;
    o.l = parseInt(Math.random() * 5) + 5;
    this.fs[i] = o;
    o.x = this.mx;
    o.y = this.my;
    }
    };
    Fireworks.prototype.flash = function() {
    if (!this.fs) this.init();
    for (var i=0; i<20; i++) {
    var o = this.fs[i];
    if (o===null) continue;
    if (o.l < 0) {
    this.fs[i] = null;
    continue;
    }
    o.vy += 0.02;
    o.x += o.vx;
    o.y += o.vy;
    o.l -= 1;
    new Point(o.x, o.y, o.r, o.g, o.b);
    }
    var me = this;
    setTimeout(function() { me.flash(); }, 100);
    };
    function mclick(event) {
    new Fireworks(mouseX(event), mouseY(event)).run();
    }
    </script>
    </head><body onmouseup="return mclick(event);"><span style="color:#fff">鼠标点一下,不要太快啊,卡哦</span></body></html>
      

  4.   


    // Fireworks.prototype.init 改成下面样子, 效果似乎更好些.
    Fireworks.prototype.init = function() {
    this.fs = [];
    for (var i=0; i<20; i++) {
    // 下面三行从循环外,移到循环内
    var r1 = 128+Math.random()*128;
    var g1 = 128+Math.random()*128;
    var b1 = 128+Math.random()*128;
    var o = {r:r1,g:g1,b:b1};
    var d = Math.random() * 2 * Math.PI;
    var d1 = Math.random();
    o.vx = Math.sin(d) * d1 * 8;
    o.vy = Math.cos(d) * d1 * 8;
    o.l = parseInt(Math.random() * 5) + 5;
    this.fs[i] = o;
    o.x = this.mx;
    o.y = this.my;
    }
    };
      

  5.   

    别急,都在潜水写,好的,我看还在后头.6000字,已添注释,已整理优化,新添math.pi圆形烟火
    <HTML><HEAD><META http-equiv='Content-Type' content='text/html;charset=utf8'>
    <TITLE>不眠夜</TITLE>
    <STYLE>font{position:absolute;z-index:2}div{position:absolute;z-index:5;}</STYLE>
    </HEAD><BODY bgcolor="black" text="white" style="overflow:hidden;">
    <div id="a" style="width:100%;height:100%;background-color:black";></div>
    <script>
    var xall=screen.availWidth,yall=screen.availHeight-180,$=Math.random
    function gcor(){return ($()*4096).toString(16)}
    onload=function(){  //启动
    var i=0;while(i++<8)setTimeout("p.add()",i*300)
    for(i=0;i++<30;)setTimeout("she.add()",i*120)
    setInterval("loadx=$()*xall;loadsize=10+($()*25);",5000)
    }var loadx=$()*xall,loadsize=10+($()*25)  //副线程1:龙蛇
    var she={
    add:function(){
    var d=document.createElement("font")
    d.color=gcor();d.dx=loadsize;d.dx2=5;d.max=5;with(d.style){fontSize=loadsize;left=loadx;top=yall;}
    d.innerText="·";d.go=setInterval(function(){she.go(d)},45);a.appendChild(d);
    },
    go:function(obj){
    var x=obj.offsetLeft,y=obj.offsetTop,dx=obj.dx,max=obj.max
    max%2==0?obj.dx2++:obj.dx2--;var dx2=obj.dx2
    if(dx2==-max||dx2==max)obj.max++
    obj.style.top=y-(dx/3);obj.style.left=x+(dx2*4)
    if(y<yall-(dx*20)){clearInterval(obj.go);a.removeChild(obj);she.add();}
    }}var p={  //1:不同上升蛋
    add:function(){
    var size1=6+($()*25),x=$()*xall
    var d=document.createElement("font"),ad=Math.ceil($()*5),t="●"
    d.color=gcor();with(d.style){fontSize=size1;left=x;top=yall;}
    if(ad==2){t="★"}else if(ad==3){t="*"}else if(ad==4){t="·"}else if(ad==5){t="◎"};
    d.innerText=t;d.ad=ad;d.go=setInterval(function(){p.go(d,size1)},35);a.appendChild(d)
    },
    go:function(obj,dx){
    var y=obj.offsetTop;obj.style.top=y-(dx/7)
    if(y<yall-(dx*15))return p.bao(obj,y)
    },
    bao:function(obj,y){
    var x=obj.offsetLeft,ad=obj.ad,s=parseInt(obj.style.fontSize),c=obj.color
    clearInterval(obj.go);
    if(ad!=3){a.removeChild(obj);p.add()}
    if(ad==1){for(var i=0;i<($()*12)+8;i++){flash1.add(x,y,s,c)}}
    else if(ad==2){for(var i=0;i<($()*12)+12;i++){flash2.add(x,y,i+10,s)}}
    else if(ad==3){
    obj.face="楷体_GB2312";obj.jia=0;obj.innerText="恭\n喜"
    obj.style.fontSize=s*3;obj.style.left=x-(s*2);obj.style.top=y-(s*2);
    clearInterval(obj.go);obj.go=setInterval(function(){p.flash3_go2(obj)},50);
    var i=0;while(i++<4){setTimeout(function(){flash3.add(x,s)},i*900)}
    }else if(ad==4){flash4.add(x,y,s,c)}
    else if(ad==5){flash5.begin(x,y,s);}
    },
    flash3_go2:function(obj){  //2:恭喜牛年发财
    var c=obj.color,r=c.substr(1,2),g=c.substr(3,2),b=c.substr(5,2),dx=8,jia=obj.jia
    r=Math.floor(("0x"+r).toString(10));g=Math.floor(("0x"+g).toString(10));b=Math.floor(("0x"+b).toString(10));
    if(jia==0){r+=dx;g+=dx;b+=dx;obj.color="rgb("+r+","+g+","+b+")"}
    else if(jia==15){r-=dx;g-=dx;b-=dx;obj.color="rgb("+r+","+g+","+b+")"}
    else{obj.color=gcor();jia++;obj.jia=jia;if(obj.jia==15)obj.innerText="发\n财"}
    if(r>255||g>255||b>255){obj.jia=1;obj.innerText="牛\n年"}
    if(r+g+b<0){clearInterval(obj.go);a.removeChild(obj);p.add()}
    }}var flash1={  //3:随机炸
    add:function(x,y,size1,color1){
    var dx=Math.round($()*50)-25,dy=Math.round($()*50)-25
    if(Math.abs(dx)<5)dx=10;if(Math.abs(dy)<5)dy=-10;
    var d=document.createElement("font");
    with(d.style){fontSize=size1;left=x;top=y;}d.color=color1;
    d.innerText="●";d.go=setInterval(function(){flash1.go(d,x,y,dx,dy)},30);a.appendChild(d)
    },
    go:function(obj,x,y,dx,dy){
    var x2=obj.offsetLeft,y2=obj.offsetTop
    if(Math.abs(x-x2)<150&&Math.abs(y-y2)<150){obj.style.left=x2+dx;obj.style.top=y2+dy;}else{clearInterval(obj.go);a.removeChild(obj);}
    }}var cn=true,flash2={  //4:阿基米德炸
    add:function(x,y,pos,size1){
    var d=document.createElement("font");
    with(d.style){fontSize=size1;left=x;top=y;}
    d.color=gcor();d.innerText="★";
    d.go=setInterval(function(){flash2.go(d,x,y,pos,cn)},30);a.appendChild(d);cn=!cn
    },
    go:function(obj,x,y,p,cn){
    var x2=obj.offsetLeft,y2=obj.offsetTop
    if(Math.abs(x-x2)<125&&Math.abs(y-y2)<125){
    if(cn){obj.style.left=x2+(p*Math.cos(p));obj.style.top=y2+(p*Math.sin(p))}else{obj.style.left=x2+(p*Math.sin(p));obj.style.top=y2+(p*Math.cos(p))}
    }else{clearInterval(obj.go);a.removeChild(obj);}
    }}var flash3={  //5:连环冲天
    add:function(x,size1){
    var arr=[],x2=$()*100-50+x,d=document.createElement("div");
    with(d.style){left=x2;top=yall;}
    for(var i=0;i++<5;){var os=size1+2-(i*2);if(os<1)os=1;arr[i]="<font color='"+gcor()+"' style='font-size:"+os+"'>*</font><br>"}
    d.innerHTML=arr.join("");d.go=setInterval(function(){flash3.go(d)},30);a.appendChild(d);
    },
    go:function(obj){
    var top1=obj.offsetTop;obj.style.top=top1-30;if(top1<-50){clearInterval(obj.go);a.removeChild(obj)}
    }}var flash4={  //6:漫天星
    add:function(x,y,size1,color1){
    var arr=[],d=document.createElement("div");d.ci=1;
    with(d.style){left=x;top=y;fontSize=size1;color=color1;}
    for(var i=0;i++<($()*60)+40;){
    var gx=size1*12,sx=$()*gx-(gx/2),sy=$()*gx-(gx/2);
    arr[i]="<font style='left:"+sx+";top:"+sy+"'>.</font>"
    }
    d.innerHTML=arr.join("");d.go=setInterval(function(){flash4.go(d)},70);a.appendChild(d);
    },
    go:function(obj){
    var ci=obj.ci++;if(ci==30){clearInterval(obj.go);return a.removeChild(obj)}
    ci%2==0?obj.style.visibility="visible":obj.style.visibility="hidden";
    }}var mp=Math.PI,lr=true,flash5={  //7:圆形花
    begin:function(x,y,s){
    var pishu=Math.round($()*10)+8,zhou=Math.round($()*100)+60
    lr=!lr;for(var i=0;i++<pishu;){var jiao=i*(360/pishu);flash5.add(x,y,s,jiao,zhou)}
    },
    add:function(x,y,s,jiao,zhou){
    var d=document.createElement("font")
    d.color=gcor();with(d.style){fontSize=s;left=x;top=y}
    d.innerText="◎";d.jiao=jiao;d.ci=0;d.lr=lr
    d.go=setInterval(function(){flash5.go(d,x+(zhou*Math.cos(jiao*mp/180)),y+(zhou*Math.sin(jiao*mp/180)),zhou)},50);a.appendChild(d);
    },
    go:function(obj,x,y,zhou){
    obj.lr?obj.jiao+=12:obj.jiao-=12;if(obj.ci++>30){clearInterval(obj.go);return a.removeChild(obj)}
    var jiao=obj.jiao
    obj.style.left=x+(zhou*Math.cos(jiao*mp/180));obj.style.top=y+(zhou*Math.sin(jiao*mp/180))
    }}
    </script></BODY></HTML>
      

  6.   

       好 都很漂亮啊 
    刚开始学JavaScript 呵呵
       
      

  7.   

    <html>
    <head><title>ialvin.cn</title>
    <style>
    body{ background:#000; padding:0; margin:0; overflow:hidden; }
    .ptr{ width:2px; height:2px; overflow:hidden; position: absolute; }
    </style>
    <script>
    var winHeight;
    function mouseX(event) { event=event||window.event; return (event.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft))||event.pageY; }
    function mouseY(event) { event=event||window.event; return (event.clientY+(document.documentElement.scrollTop||document.body.scrollTop))||event.pageY; }
    function getWindowHeight() { return window.innerHeight || document.body.clientHeight; }
    window.onload = function(e) { winHeight = getWindowHeight(); };function setColor(p) {
        p.r=parseInt(p.r/2); p.g=parseInt(p.g/2); p.b=parseInt(p.b/2);
        if (p.r==0 && p.g==0 && p.b==0) return document.body.removeChild(p.ptr);
        p.ptr.style.background = "rgb("+p.r+","+p.g+","+p.b+")";
        setTimeout(function(){setColor(p);}, 150);
    }
    function Point(x, y, r, g, b) {
        this.ptr = document.createElement("DIV");
        this.ptr.className = "ptr";
        document.body.appendChild(this.ptr);
        this.ptr.style.left = x + "px";
        this.ptr.style.top  = y + "px";
        this.r = 2*r;
        this.g = 2*g;
        this.b = 2*b;
        var p = this;
        setTimeout(function(){setColor(p)}, Math.random()*200);
    }
    function Fireworks(mx, my) {
        this.mx = mx;
        this.my = my;
        this.cx = mx;
        this.cy = winHeight;
    }
    Fireworks.prototype.run = function() {
        if (this.cy <= this.my) return this.flash();
        new Point(this.cx, this.cy, 0x40, 0x40, 0x40);
        this.cy -= 10;
        var self = this;
        setTimeout( function(){self.run();}, 50);
    };
    Fireworks.prototype.init = function() {
        this.fs = [];
        var r1 = 128+Math.random()*128;
        var g1 = 128+Math.random()*128;
        var b1 = 128+Math.random()*128;
        for (var i=0; i<20; i++) {
            var o = {r:r1,g:g1,b:b1};
            var d = Math.random() * 2 * Math.PI;
            var d1 = Math.random();
            o.vx = Math.sin(d) * d1 * 8;
            o.vy = Math.cos(d) * d1 * 8;
            o.l = parseInt(Math.random() * 5) + 5;
            this.fs[i] = o;
            o.x = this.mx;
            o.y = this.my;
        }
    };
    Fireworks.prototype.flash = function() {
        if (!this.fs) this.init();
        for (var i=0; i<20; i++) {
            var o = this.fs[i];
            if (o===null) continue;
            if (o.l < 0) {
                this.fs[i] = null;
                continue;
            }
            o.vy += 0.02;
            o.x += o.vx;
            o.y += o.vy;
            o.l -= 1;
            new Point(o.x, o.y, o.r, o.g, o.b);
        }
        var me = this;
        setTimeout(function() { me.flash(); }, 100);
    };
    function mclick(event) {
        new Fireworks(mouseX(event), mouseY(event)).run();
    }
    </script>
    </head><body onmouseup="return mclick(event);"><span style="color:#fff">鼠标点一下,不要太快啊,卡哦</span></body></html>
      

  8.   

    firework.js代码 : var Utils={};Utils.$E=function(id){
        return document.getElementById(id);
    };Utils.$C=function(tagName){
        return document.createElement(tagName);
    };Utils.getIntervalRandom=function(min,max){
        return parseInt(Math.random()*(max-min)+min);
    };Utils.INTERVAL_SPEED=30;
    if(navigator.appName.toLowerCase().indexOf("netscape")!=-1)
    {
        Utils.INTERVAL_SPEED=Utils.INTERVAL_SPEED+(Utils.INTERVAL_SPEED/6);
    }String.prototype.padLeft=function(sLen,padChar){
        var result=this;
        for(i=this.length;i<sLen;i++){
            result=padChar+result;
        }
        return result;
    };
    var Firework=function(x,shotHeight,radius,particleCount,color,speed){
        this.shotHeight=shotHeight || 200;
        this.radius=radius || 100;
        this.particleCount=particleCount || 10;
        this.color=color || "#FF0000";
        this.parentElement=document.body;
        this.x=x;
        this.shottingSpeed=speed || 3;
        this.isShoted=false;
        this.isFlash=true;
        
        this._particles=[];
        this._particleShape=unescape("%u25CF");
        this._shottingShape="|";
        this._depth=3;
        this._shotting=Utils.$C("div");
        this._flashing=Utils.$C("div");
        this._disposeCount=0;
        
        var _this=this;
        
        void function initialize(){
            for(var i=0;i<_this.particleCount;i++){
                _this._particles[i]=Utils.$C("div");
                _this._particles[i].style.position="absolute";
                _this._particles[i].style.left=_this.x+"px";
                _this._particles[i].style.top=_this.shotHeight+"px";
                _this._particles[i].style.zIndex=100;
                _this._particles[i].style.color=_this.color;
                _this._particles[i].style.display="none";
                _this._particles[i].innerHTML=_this._particleShape;
                _this._particles[i].distance=Utils.getIntervalRandom(1,_this.radius-parseInt((i%_this._depth)*(_this.radius/_this._depth)));
                _this._particles[i].speed=Utils.getIntervalRandom(1,4)*_this._particles[i].distance*0.06;
                _this.parentElement.appendChild(_this._particles[i]);
                _this._setSize(_this._particles[i],5);
            }
            
            _this._shotting.speed=_this.shottingSpeed;
            _this._shotting.innerHTML=_this._shottingShape;
            _this._shotting.style.position="absolute";
            _this._shotting.style.fontWeight="900";
            _this._shotting.style.left=_this.x+"px";
            //_this._shotting.style.top=_this.parentElement.offsetTop+_this.parentElement.offsetHeight-_this._shotting.offsetHeight+"px";
            _this._shotting.style.top="700px";
            _this._shotting.style.zIndex=100;
            _this._shotting.style.color=_this.color;
            _this._setSize(_this._shotting,15);
            _this.parentElement.appendChild(_this._shotting);
            
            _this._flashing.style.width="100%";
            _this._flashing.style.height="100%";
            _this._flashing.style.left="0";
            _this._flashing.style.top="0";
            _this._flashing.style.backgroundColor="#ffffee";
            _this._flashing.style.position="absolute";
            _this._flashing.style.zIndex=200;
            _this._flashing.style.display="none";
            _this._flashing.style.MozOpacity=0.5;
            _this._flashing.style.filter="alpha(opacity=50)";
            _this.parentElement.appendChild(_this._flashing);
            
        }();
    };Firework.prototype.shot=function(){
        var _this=this;
        _this.isShoted=true;
        var shotInterval=window.setInterval(function(){
            if(parseInt(_this._shotting.style.top)>_this.shotHeight){
                _this._shotting.style.top=parseInt(_this._shotting.style.top)-_this._shotting.speed+"px";
            }
            else{
                window.clearInterval(shotInterval);
                _this.parentElement.removeChild(_this._shotting);
                _this.bomb();
                _this._shotting=null;
            }    
        },Utils.INTERVAL_SPEED);
    };Firework.prototype.bomb=function(){
        var _this=this;
        if(_this.isFlash){
            _this._flashing.style.display="";
            var flashTimeout=window.setTimeout(function(){
                _this.parentElement.removeChild(_this._flashing);
                window.clearTimeout(flashTimeout);
            },10);
        }
        else{
            _this.parentElement.removeChild(_this._flashing);
        }
        
        for (var i = 0; i <_this._particles.length; i++) {
            _this._moveParticle(_this._particles[i], Utils.getIntervalRandom(0,360));
        }
    };Firework.prototype._setSize=function(obj,value){
        obj.style.fontSize=parseInt(value)+"px";
    };Firework.prototype._moveParticle=function(particle,angle){
        var _this=this;
        var initX=parseInt(particle.style.left);
        var initY=parseInt(particle.style.top);
        var currentDistance=0;
        var currentX=initX;
        var currentY=initY;
        particle.style.display="";
        
        particle.intervalId=window.setInterval(function(){
            if(currentDistance<particle.distance){
                var newX,newY;
                var xAngle=angle*(2*Math.PI/360);
                var xDirection=Math.abs(Math.cos(xAngle))/Math.cos(xAngle);
                var yDirection=Math.abs(Math.sin(xAngle))/Math.sin(xAngle);
        
                if(Math.abs(Math.tan(xAngle))<=1){
                    var deltaX=Math.abs(particle.speed*Math.cos(xAngle))*xDirection;
                    newX=currentX+deltaX;
                    newY=-(newX-initX)*Math.tan(xAngle)+initY;
                    currentDistance+=Math.abs(deltaX);
                }
                else{
                    var deltaY=Math.abs(particle.speed*Math.sin(xAngle))*yDirection;
                    newY=currentY-deltaY;
                    newX=-(newY-initY)/Math.tan(xAngle)+initX;
                    currentDistance+=Math.abs(deltaY);
                }
                currentX=newX;
                currentY=newY;
                particle.style.left=currentX+"px";
                particle.style.top=currentY+"px";
            }
            else{
                window.clearInterval(particle.intervalId);
                _this.parentElement.removeChild(particle);
                particle=null;
                if(++_this._disposeCount==_this.particleCount){
                    _this._particles.length=0;
                    _this.parentElement=null;
                    _this=null;
                }
            }
        },Utils.INTERVAL_SPEED);};
      

  9.   

    HTML代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <script type="text/javascript" src="firework.js"></script>
            <script type="text/javascript">
                function test(){
                    var fireworks=[];
                    var total=15;
                    window.setInterval(function(){
                        for (var i = 0; i < total; i++) {
                            if (!fireworks[i] || !fireworks[i].parentElement) {
                                var x=Utils.getIntervalRandom(50,document.body.offsetWidth-50);
                                var shotHeight=Utils.getIntervalRandom(100,450);
                                var radius=Utils.getIntervalRandom(50,200);
                                var particleCount=Utils.getIntervalRandom(40,80);
                                var speed=Utils.getIntervalRandom(10,20);
                                var color="#"+Utils.getIntervalRandom(0,16777215).toString(16).padLeft(6,"f");
                                fireworks[i] = new Firework(x, shotHeight, radius, particleCount, color, speed);
                            }
                        }
                    },100);
                    
                    window.setInterval(function(){
                        var currentIndex=Utils.getIntervalRandom(0,total);
                        if(fireworks[currentIndex] && fireworks[currentIndex].parentElement && !fireworks[currentIndex].isShoted){
                            fireworks[currentIndex].shot();
                        }
                    },500);
                }
            </script>
        </head>
        <body bgColor="#000000" onload="test();">
            <div style="width:100%;text-align:center;font:100px 'Comic Sans MS',Arial,sans-serif;color:yellow;">Happy New Year</div>
            <div style="width:100%;text-align:center;font:100px 'Comic Sans MS',Arial,sans-serif;color:red;">2009</div>
            <a href="http://random.cnblogs.com" target="newWindow"><div style="width:100%;font-size:12px;text-align:center;color:#fff">Copyright by Random 2009 All Rights Reserved</div></a>
        </body>
    </html>
      

  10.   

    看代码,原作者是:http://random.cnblogs.com【编程游戏】贺岁放礼花。(点燃续帖1-141楼YH_Random的焰火)
      

  11.   

    我也来凑凑热闹,爆炸算法有些问题,不过今天没时间管他了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Untitled Page</title>
        <style type="text/css">
        body{margin:0px;padding:0px;width:100%;height:100%;background-color:#000000;color:#ffffff;}
        div{overflow:hidden;}
        </style>
    </head>
    <body></body>
    <script type="text/javascript">
        function changeOpac(opacity, id) { 
        var object = document.getElementById(id).style; 
        object.opacity = (opacity / 100); 
        object.MozOpacity = (opacity / 100); 
        object.KhtmlOpacity = (opacity / 100); 
        object.filter = "alpha(opacity=" + opacity + ")"; 
        }
        function Random(start,end){if(start||end) return Math.round(start+Math.random()*(end-start));else return Math.random();}
        function Sparks(point,count,r,g,b,sky)
        {
            var da=360/count;
            var r=Random(50,150);
            var step=Random(5,20);
            for(var i=0;i<count;i++)
            {
                var ele=document.createElement("div");
                ele.pos=function(point){if(point){this.style.left=point.x+"px";this.style.top=point.y+"px";}else{return new Point(this.offsetLeft,this.offsetTop);}};
                ele.size=function(size){if(size){this.style.width=size.x+"px";this.style.height=size.y+"px";}else{return new Point(this.offsetWidth,this.offsetHeight)}};
                ele.opac=function(o){this.style.opacity = (o / 100);this.style.MozOpacity=o/100;this.style.KhtmlOpacity=o/100;this.style.filter= "alpha(opacity=" + o + ")";};
                ele.r=r;
                ele.nstep=0;
                ele.step=step;
                ele.d=da*i;
                ele.spoint=point;
                sky.appendChild(ele);
                ele.style.position="absolute";
                ele.size(new Point(10,10));
                ele.style.backgroundColor="rgb("+r+","+g+","+b+")";
                ele.pos(new Point(point.x-5,point.y-5));
                ele.run=function()
                {
                    if(this.nstep>=this.step)
                    {
                        this.parentNode.removeChild(this);return;
                    }
                    this.nstep++;
                    var nr=(this.r/this.step)*this.nstep;
                    this.pos(new Point(nr*Math.cos(this.d)+this.spoint.x-5,nr*Math.sin(this.d)+this.spoint.y-5));
                    var obj=this;
                    setTimeout(function(){obj.run();},200);
                }
                ele.run();
            }
        }
        function Point(x,y){this.x=x;this.y=y;}
        ({
            fire:function(){
            var r=Random(0,255);var g=Random(0,255);var b=Random(0,255);
            var pos=Random(100,this.sky.width-100);
            new this.fireWork(r,g,b,pos,this.sky);var obj=this;setTimeout(function(){obj.fire();},1000);},
            sky:(function(){
                                var obj=document.body;
                                obj.width=document.documentElement.clientWidth;
                                obj.height=document.documentElement.clientHeight;
                                return obj;
                            })(),
            fireWork:function(r,g,b,position,sky)
                    {
                        this.ele=document.createElement("div");
                        this.ele.style.position="absolute";
                        this.sky=sky;
                        this.color={"r":r,"g":g,"b":b};
                        this.ele.pos=function(point){if(point){this.style.left=point.x+"px";this.style.top=point.y+"px";}else{return new Point(this.offsetLeft,this.offsetTop);}};
                        //this.ele.size=function(size){if(size){this.style.width=size.x+"px";this.style.height=size.y+"px";}else{return new Point(this.offsetWidth,this.offsetHeight)}};
                        //this.ele.opac=function(o){this.style.opacity = (o / 100);this.style.MozOpacity=o/100;this.style.KhtmlOpacity=o/100;this.style.filter= "alpha(opacity=" + o + ")";};
                        this.flyH=this.sky.height-Random(200,this.sky.height*0.8);
                        this.ele.pos(new Point(position,this.sky.height-10));
                        this.ele.style.backgroundColor="rgb("+r+","+g+","+b+")";
                        this.ele.style.width="10px";
                        this.ele.style.height="10px"
                        document.body.appendChild(this.ele);
                        this.fire=function(){if(this.ele.pos().y<=this.flyH){var bomb=new Sparks(this.ele.pos(),Random(4,12),this.color.r,this.color.g,this.color.b,this.sky);this.ele.parentNode.removeChild(this.ele);return;}var pos=this.ele.pos();this.ele.pos(new Point(pos.x,pos.y-20));var obj=this;setTimeout(function(){obj.fire();},100);};
                        this.bomb=function(){};
                        this.fire();
                    }
        }).fire();
    </script>
    </html>