|
页面游动吐泡小鱼
以下是代码片段: <html>
<body onLoad="Start()"> <script language="JavaScript"> <!-- Image0=new Image(); Image0.src="http://www.jscode.cn/Uploadfile/2006515152552219.GIF"; Amount=12; Pics=new Array(); Load=new Array(); Ypos=new Array(); Xpos=new Array(); Speed=new Array(); Rate=new Array(); Grow=new Array(); Step=new Array(); Cstep=new Array(); NsSize=new Array(); Ns=(document.layers)?1:0; Pos=-1; Jog=1; Timer=null; for(i=0; i <= 6; i++) function PreLoad(){ for(i=0; i < Pics.length; i++){ Load[i]=new Image(); Load[i].src=Pics[i]; } } PreLoad(); Strt=0-(Load[0].width+50); function AniFish(){ Pos+=Jog; if (Pos >= Pics.length) Pos=0; if (Ns) document.nfish.document.images.nframe.src=Pics[Pos]; else document.images.iframe.src=Pics[Pos]; Timer=setTimeout('AniFish()',50) } function MoveFish(){ H=(document.layers)?window.innerHeight+window.pageYOffset:window.document.body.clientHeight+document.body.scrollTop; W=(document.layers)?window.innerWidth+window.pageXOffset:window.document.body.clientWidth+document.body.scrollLeft; Strt-=2; if (Strt < 0-(Load[0].width)) Strt=W; if (Ns) else setTimeout('MoveFish()',10) } H2=(document.layers)?window.innerHeight:window.document.body.clientHeight; for (i=0; i < Amount; i++) if (Ns){ for (i = 0; i < Amount; i++){ document.write("<layer name='sn"+i+"' left=0 top=-50><img src="+Image0.src+" name='N' width="+NsSize[i]+" height="+NsSize[i]+"></layer>"); } document.write("<layer name='nfish' left=0 top=-50><img src='0.gif' name='nframe'></layer>"); } else{ document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">'); for (i = 0; i < Amount; i++){ document.write('<img id="si" src="'+Image0.src+'" style="position:absolute;top:-100px;left:0px;filter:alpha(opacity=90)">'); } document.write('</div></div>'); document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">' +'<img id="ifish" src="0.gif" name="iframe" style="position:absolute;top:-100px;left:0px"></div></div>'); } function Bubbles(){ Hs=(document.layers)?window.pageYOffset:document.body.scrollTop; Ws=(document.layers)?window.pageXOffset:document.body.scrollLeft; for (i=0; i < Amount; i++){ sy = Speed[i]*Math.sin(270*Math.PI/180); sx = Speed[i]*Math.cos(Cstep[i]*5); Ypos[i]+=sy; Xpos[i]+=sx; if (Ypos[i] < -40){ if (Ns) else Speed[i]= 6+Math.random()*3; Grow[i]=4; NsSize[i]=Math.random()*4+6; } if (Ns) else Grow[i]+=Rate[i]; Cstep[i]+=Step[i]; if (Grow[i] > 15) Grow[i]=16; } setTimeout('Bubbles()',10); } function Start() //--> </script> </body>
</html>
检测代码效果 请进
|