»
EnglishFrenchVietnamese

Print - SnowFall - JavaScriptBank.com

Full version: jsB@nk » Multimedia » Events » SnowFall
URL: https://www.javascriptbank.com/snowfall.html

SnowFall © JavaScriptBank.comThis JavaScript depicts falling snow. You can specify how many flakes to fall and how fast.

Full version: jsB@nk » Multimedia » Events » SnowFall
URL: https://www.javascriptbank.com/snowfall.html



CSS
<style type="text/css">.snow {position:absolute;layer-background-color:lightblue;visibility:visible;top:-50px;font-size:1px;background-color:lightblue;}body{background-color:black;font-size:10pt;color:white;font-family:sans-serif;}</style><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<script language="javascript">var snowflakes=50;          //NUMBER OF OBJECTS YOU WANT.var level=2;                      //SPEED LEVEL 1 to 5. 1=SLOWER, 5=FASTERvar w3c=(document.getElementById)?true:false;var ns4=(document.layers)?true:false;var ie4=(document.all && !w3c)?true:false;var ie5=(document.all && w3c)?true:false;var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;var t='';var w_x, w_y;var snow=new Array();for(i=1;i<=snowflakes;i++)t+='<div id="snow'+i+'" class="snow"></div>';document.write(t);function getstartpos(obj){obj.size=Math.floor(Math.random()*5)+1obj.ystep=obj.size*level;obj.xstep=obj.ystep/5;if(ns4)obj.clip.width=obj.clip.height=obj.size;else obj.style.width=obj.style.height=obj.size;moveidto(obj,Math.floor(Math.random()*w_x)-obj.size,0);}function movedrop(){for(i=1;i<=snowflakes;i++){var l=(ns4)?snow[i].left:parseInt(snow[i].style.left);var t=(ns4)?snow[i].top:parseInt(snow[i].style.top);var pxo=(ie4||ie5)?document.body.scrollLeft:pageXOffset;var pyo=(ie4||ie5)?document.body.scrollTop:pageYOffset;if( (t+snow[i].ystep+snow[i].size>=w_y+pyo) || (snow[i].xpos-snow[i].size<pxo)) getstartpos(snow[i]);else moveidto(snow[i], l-snow[i].xstep, t+snow[i].ystep);}}function getwindowdims(){w_x=(ie4||ie5)? document.body.clientWidth:window.innerWidth;w_y=(ie4||ie5)? document.body.clientHeight:window.innerHeight;}function moveidto(id,x,y){if(ns4)id.moveTo(x,y);else{id.style.left=x+'px';id.style.top=y+'px';}}window.onresize=function(){if(ns4)setTimeout('history.go(0)',400);else getwindowdims();}window.onload=function(){level=Math.max(Math.min(5,level),1)getwindowdims();for(i=1;i<=snowflakes;i++){snow[i]=(ns4)?document.layers['snow'+i]:(ie4)?document.all['snow'+i]:document.getElementById('snow'+i);getstartpos(snow[i]);moveidto(snow[i],Math.floor(Math.random()*(w_x-10)),Math.floor(Math.random()*(w_y-10)));}setInterval('movedrop()',50);}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->