The second JavaScript fireworks code explodes a graph, and javascript fireworks
<! 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>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> second JavaScript fireworks code explosion graphics </title>
<Script type = "text/javascript">
Var firework = function (){
This. size = 40;
This. speed = 0.1;
This. rise ();
}
Firework. prototype = {
Color: function (){
Var c = ['0', '3', '6', '9', 'C', 'F'];
Var t = [c [Math. floor (Math. random () * 100) % 6], '0', 'F'];
T. sort (function () {return Math. random ()> 0.5? -1:1 ;});
Return '#' + t. join ('');
},
Aheight: function (){
Var h = document.doc umentElement. clientHeight;
Return Math. abs (Math. floor (Math. random () * h-200) + 201;
},
Firecracker: function (){
Var B = document. createElement ('div ');
Var w = document. body. clientWidth;
B. style. color = this. color ();
B. style. position = 'absolute ';
B. style. bottom = 0;
B. style. left = Math. floor (Math. random () * w) + 1 + 'px ';
Document. body. appendChild (B );
Return B;
},
Rise: function (){
Var o = this. firecracker ();
Var n = this. aheight ();
Var speed = this. speed;
Var e = this. expl;
Var s = this. size;
Var k = n;
Var m = function (){
O. style. bottom = parseFloat (o. style. bottom) + k * speed + 'px ';
K-= k * speed;
If (k <2 ){
ClearInterval (clear );
E (o, n, s, speed );
}
}
O. innerHTML = '*';
If (parseInt (o. style. bottom) <n ){
Var clear = setInterval (m, 20 );
}
},
Expl: function (o, n, s, speed ){
Var R = n/3;
Var Ri = n/6;
Var r = 0;
Var ri = 0;
For (var I = 0; I <s; I ++ ){
Var span = document. createElement ('span ');
Var p = document. createElement ('P ');
Span. style. position = 'absolute ';
Span. style. left = 0;
Span. style. top = 0;
Span. innerHTML = '*';
P. style. position = 'absolute ';
P. style. left = 0;
P. style. top = 0;
P. innerHTML = '+ ';
O. appendChild (span );
O. appendChild (p );
}
Function spr (){
R + = R * speed;
Ri + = Ri * speed/2;
Sp = o. getElementsByTagName ('span ');
P = o. getElementsByTagName ('P ');
For (var I = 0; I <sp. length; I ++ ){
Sp [I]. style. left = r * Math. cos (360/s * I) + 'px ';
Sp [I]. style. top = r * Math. sin (360/s * I) + 'px ';
P [I]. style. left = ri * Math. cos (360/s * I) + 'px ';
P [I]. style. top = ri * Math. sin (360/s * I) + 'px ';
}
R-= R * speed;
If (R <2 ){
ClearInterval (clearI );
O. parentNode. removeChild (o );
}
}
Var clearI = setInterval (spr, 20 );
}
}
Window. onload = function (){
Function happyNewYear (){
New firework ();
}
SetInterval (happyNewYear, 400 );
}
</Script>
<Style type = "text/css">
</Style>
</Head>
<Body style = "background: #000; font: 12px Arial">
<Div> <A href = "http://www.999jiujiu.com/"> http://www.999jiujiu.com/</A> </div>
</Body>
</Html>