The code is:
var no = 8;
var otime = new Date ();
var lasttime = Otime.gettime ();
var x_sin, X_point, Y_point;
var x_length, x_increased, y_increased;
var i, Body_width = 932, body_height = 538;
var lasttime = 0;
var fallinterval = 2.4;
X_sin = new Array ();
X_point = new Array ();
Y_point = new Array ();
X_length = new Array ();
x_increased = new Array ();
y_increased = new Array ();
var obody = document.body;
var d=document;
/*body_width = Obody.clientwidth;
Body_height = obody.clientheight;*/
for (i = 0; i < no; + i) {
Snowflakeimgno = Math.Round (Math.random () * (snowflake.length-1));
X_sin[i] = 0;
X_point[i] = Math.random () * (body_width-250) +100;
Y_point[i] = Math.random () *body_height;
X_length[i] = Math.random () *20;
X_increased[i] = 0.02 + math.random ()/10;
Y_increased[i] = 0.7 + math.random ();
X_increased[i] = 0.08 + math.random ()/5;
Y_increased[i] = 2.7 + math.random () *2;
D.write ("<div id=\" snowflakediv_ "+ i +" \ "style=\" Position:absolute; z-index:11; visibility:visible; top:15px; left : 215px;\ "></div> ");
}
function Snowflakefloat () {
var now = new Date ();
var second = Now.gettime ();
var scrolltop = Document.body.scrollTop;
var snowflakediv_0 = d.getElementById ("Snowflakediv_0");
var snowflakediv_1 = d.getElementById ("Snowflakediv_1");
var snowflakediv_2 = d.getElementById ("snowflakediv_2");
var snowflakediv_3 = d.getElementById ("Snowflakediv_3");
var snowflakediv_4 = d.getElementById ("Snowflakediv_4");
var snowflakediv_5 = d.getElementById ("Snowflakediv_5");
var snowflakediv_6 = d.getElementById ("Snowflakediv_6");
var snowflakediv_7 = d.getElementById ("snowflakediv_7");
for (i = 0; i < no; i++) {
if (Y_point[i] >= 0) {
Y_point[i] + = Y_increased[i];
}
if (Y_point[i] > scrolltop + body_height-10 | | y_point[i] < scrolltop | | y_point[i] < 0) {//Remove window , or in the waiting queue
if ((second-lasttime)/1000 > Fallinterval) {//drop from queue
Snowflakeimgno = Math.Round (Math.random () * (snowflake.length-1));
if (document.getElementById (' Snowimg_ ' +i)) {
document.getElementById (' Snowimg_ ' +i). src = Snowflake[snowflakeimgno];
}
X_point[i] = Math.random () * (body_width-x_length[i]-250) + 100;
Y_point[i] = scrolltop;
X_increased[i] = 0.05 + math.random ()/2;
Y_increased[i] = 2.7 + math.random ()/2;
X_increased[i] = 0.05;
Y_increased[i] = 2.7;
Body_width = Obody.clientwidth;
Body_height = Obody.clientheight;
Lasttime = second;
}else {
Y_point[i] =-50;
}
}
X_sin[i] + = X_increased[i];
Eval ("Snowflakediv_" +i). Style.pixeltop = Y_point[i];
Eval ("Snowflakediv_" +i). Style.pixelleft = X_point[i] + x_length[i]*math.sin (x_sin[i));
}
}
Window.setinterval ("Snowflakefloat ()", 100);
2. In the page you need to link code files: <script language=javascript src= "floating. js" ></SCRIPT>
3.
Add a picture
The code is:
Reference:
<script language=javascript>
I only added three pictures, in fact, you can add several pictures, picture files generally small.
var snowflake = new Array ();
Snowflake[0] = ' float1.gif ';//Picture One
Snowflake[1] = ' float2.gif ';//Picture Two
SNOWFLAKE[2] = ' float3.gif ';//Picture Three
</SCRIPT>