标签:
1 <html> 2 <head> 3 <title>全屏雪花飘落的背景特效丨电表控制器</title> 4 <script language="JavaScript"> 5 <!-- 6 Amount=20; //Smoothness! depends on image file size, the smaller the size the more you can use! 7 //Pre-load your image below! 8 Image0=new Image(); 9 Image0.src="/html/txdm_2/images/20101019/flake1.gif"; 10 Image1=new Image(); 11 Image1.src="/html/txdm_2/images/20101019/flake2.gif"; 12 Image2=new Image(); 13 Image2.src="/html/txdm_2/images/20101019/flake3.gif"; 14 Image3=new Image(); 15 Image3.src="/html/txdm_2/images/20101019/flake4.gif"; 16 Image4=new Image(); 17 Image4.src="/html/txdm_2/images/20101019/flake5.gif"; 18 grphcs=new Array(5) 19 grphcs[0]="/html/txdm_2/images/20101019/flake1.gif" 20 grphcs[1]="/html/txdm_2/images/20101019/flake2.gif" 21 grphcs[2]="/html/txdm_2/images/20101019/flake3.gif" 22 grphcs[3]="/html/txdm_2/images/20101019/flake4.gif" 23 grphcs[4]="/html/txdm_2/images/20101019/flake5.gif" 24 Ypos=new Array(); 25 Xpos=new Array(); 26 Speed=new Array(); 27 Step=new Array(); 28 Cstep=new Array(); 29 ns=(document.layers)?1:0; 30 if (ns){ 31 for (i = 0; i < Amount; i++){ 32 var P=Math.floor(Math.random()*grphcs.length); 33 rndPic=grphcs[P]; 34 document.write("<LAYER NAME=‘sn"+i+"‘ LEFT=0 TOP=0><img src="+rndPic+"></LAYER>"); 35 } 36 } 37 else{ 38 document.write(‘<div style="position:absolute;top:0px;left:0px"><div style="position:relative">‘); 39 for (i = 0; i < Amount; i++){ 40 var P=Math.floor(Math.random()*grphcs.length); 41 rndPic=grphcs[P]; 42 document.write(‘<img id="si" src="‘+rndPic+‘" style="position:absolute;top:0px;left:0px">‘); 43 } 44 document.write(‘</div></div>‘); 45 } 46 WinHeight=(document.layers)?window.innerHeight:window.document.body.clientHeight; 47 WinWidth=(document.layers)?window.innerWidth:window.document.body.clientWidth; 48 for (i=0; i < Amount; i++){ 49 Ypos[i] = Math.round(Math.random()*WinHeight); 50 Xpos[i] = Math.round(Math.random()*WinWidth); 51 Speed[i]= Math.random()*3+2; 52 Cstep[i]=0; 53 Step[i]=Math.random()*0.1+0.05; 54 } 55 function fall(){ 56 var WinHeight=(document.layers)?window.innerHeight:window.document.body.clientHeight; 57 var WinWidth=(document.layers)?window.innerWidth:window.document.body.clientWidth; 58 var hscrll=(document.layers)?window.pageYOffset:document.body.scrollTop; 59 var wscrll=(document.layers)?window.pageXOffset:document.body.scrollLeft; 60 for (i=0; i < Amount; i++){ 61 sy = Speed[i]*Math.sin(90*Math.PI/180); 62 sx = Speed[i]*Math.cos(Cstep[i]); 63 Ypos[i]+=sy; 64 Xpos[i]+=sx; 65 if (Ypos[i] > WinHeight){ 66 Ypos[i]=-60; 67 Xpos[i]=Math.round(Math.random()*WinWidth); 68 Speed[i]=Math.random()*5+2; 69 } 70 if (ns){ 71 document.layers[‘sn‘+i].left=Xpos[i]; 72 document.layers[‘sn‘+i].top=Ypos[i]+hscrll; 73 } 74 else{ 75 si[i].style.pixelLeft=Xpos[i]; 76 si[i].style.pixelTop=Ypos[i]+hscrll; 77 } 78 Cstep[i]+=Step[i]; 79 } 80 setTimeout(‘fall()‘,10); 81 } 82 //--> 83 </script> 84 </head> 85 <body onLoad="fall()"> 86 </body> 87
标签:
原文地址:http://www.cnblogs.com/zhaozzm/p/4601632.html