2008年8月29日

疯狂攻击鼠标

代码效果:疯狂攻击鼠标。

代码如下:

<!--将以下代码加入HTML的<Body></Body>之间--><br /><SCRIPT language=JavaScript><br /><!--<br />var speed=20,divTop=0,divLeft=0,angle=0,ypos=0,xpos=0,amount=13;<br />if (document.layers){<br />for (i = 0; i < amount; i++)<br />{document.write('<layer name=nsa'+i+' top=0 left=0 width='+i/3+' height='+i/3+' bgcolor=#ffffff></layer>');}<br />window.captureEvents(Event.MOUSEMOVE);<br />function nsMouse(evnt){<br />xpos=evnt.pageX;ypos=evnt.pageY;<br />}<br />window.onMouseMove = nsMouse;<br />}<br />else if (document.all){<br />document.write('<div style="position:absolute;top:0px;left:0px">');<br />document.write('<div style="position:relative">');<br />for (i = 0; i < amount; i++)<br />{document.write('<div id=k style="position:absolute;top:0px;left:0px;width:'+i/3+';height:'+i/3+';background:#ffffff;font-size:'+i/3+'"></div>')}<br />document.write('</div></div>');<br />function iMouse(){xpos=event.x;ypos=document.body.scrollTop+event.y}<br />document.onmousemove = iMouse;<br />}<br />function getAngle(){<br />Y = ypos - divTop;X = xpos - divLeft;angle = Math.round(Math.atan2(Y,X) * 180/Math.PI);<br />if (angle < 0)angle += 360;<br />}<br />function bomb(){<br />if (document.layers){<br />Yscroll=window.pageYOffset;<br />ybase=Math.round(Math.random()*window.innerHeight);xbase=Math.round(Math.random()*window.innerWidth);<br />yybase=window.innerHeight-10;xxbase=window.innerWidth-10;<br />}<br />else if (document.all){<br />Yscroll=document.body.scrollTop;<br />ybase=Math.round(Math.random()*window.document.body.offsetHeight);xbase=Math.round(Math.random()*window.document.body.offsetWidth);<br />xxbase=window.document.body.offsetWidth-10;yybase=window.document.body.offsetHeight-10;<br />}<br />if ((xbase > 10 && xbase < xxbase) && (ybase > 10 && ybase < yybase))<br />bomb();<br />else<br /> {<br /> if ((divLeft > xpos-speed/1.5) && (divLeft < xpos+speed/1.5) && (divTop >= ypos-speed/1.5) && (divTop <= ypos+speed/1.5))<br /> {divTop=ybase+Yscroll;divLeft=xbase}<br />y = Math.round(speed*Math.sin(angle*Math.PI/180));x = Math.round(speed*Math.cos(angle*Math.PI/180));<br />divTop+=y;divLeft+=x;<br />getAngle();<br />T=setTimeout('bomb()',20);<br /> }<br />}<br />function Split(){<br />Clrs=new Array('fff000','ffffff','ffa500')<br />var ntscp=document.layers,msie=document.all;<br /><br />if (document.layers){<br />for (i = 0; i < amount; i++)<br />{<br /> if (i < amount-1) <br /> {ntscp['nsa'+i].top=ntscp['nsa'+(i+1)].top;ntscp['nsa'+i].left=ntscp['nsa'+(i+1)].left} <br />else <br /> {ntscp['nsa'+i].top=divTop;ntscp['nsa'+i].left=divLeft}<br />}<br />}<br />else if (document.all){<br />for (i = 0; i < amount; i++)<br />{<br /> if (i < amount-1) <br /> {msie.k[i].style.top=msie.k[i+1].style.top;msie.k[i].style.left=msie.k[i+1].style.left} <br /> else <br /> {msie.k[i].style.top=divTop;msie.k[i].style.left=divLeft}<br />}<br />}<br />for (i=0; i < amount-1; i++)<br /> {<br /> for (n=0; n < Clrs.length; n++)<br /> {var x=Math.round(Math.random()*n)}<br /> if (document.layers){ntscp['nsa'+i].bgColor=Clrs[x]}<br /> else if (document.all){msie.k[i].style.background=Clrs[x]}<br /> }<br />setTimeout("Split()",20);<br />}<br />function StArT(){bomb();Split()}<br />window.onload=StArT;<br />//--><br /></SCRIPT><br />

没有评论: