SOURCE

console 命令行工具 X clear

                    
>
console
window.onload = function(){
				var oSnow =  document.querySelector('#snow');
				//alert(oSnow)
				//创建一个对象
				function obj(){};
				//为这个对象添加一个具有参数的原型方法
				obj.prototype.draw = function(o){
					//雪花每次下落的数值
					var speed = 0;
					//设置雪花随机开始的x的位置
					var startPosLeft = Math.ceil(Math.random()*document.documentElement.clientWidth);
					//设置透明度
					o.style.opacity = (Math.ceil(Math.random()*3)+7)/10;
					o.style.left = startPosLeft + 'px';
					o.style.color = '#fff';
					//o.style.fontsize = 12+Math.ceil(Math.random()*14)+'px';
					
					//开定时器;
					setInterval(function(){
						//雪花下落的top值距离屏幕的可视区域高时执行下列
						if(speed<document.documentElement.clientHeight){
							o.style.top = speed + 'px';
							o.style.left=startPosLeft+Math.ceil(Math.random()*10)+'px';
							speed+=10;
						}else{
							o.style.display= 'none'
						}
					},500)
				};
				//使用定时器一秒创建一个雪花
				setInterval(function(){
					var oBox = document.createElement('div');
					oBox.innerHTML = '*';
					oBox.style.fontSize = 30 +'px'
					oBox.style.position = 'absolute';
					oSnow.appendChild(oBox);
					var obj1 = new obj();
					obj1.draw(oBox)
				},1000)
				
			}
<div id="snow" style="position: relative;"></div>