#1 拖著尾巴滑鼠游標 - 蛙 (Administrator) 發表於 10-6-2012 09:15
<P><FONT color=purple><FONT size=3></FONT></FONT> </P><P><FONT color=purple><FONT size=3></FONT></FONT> </P>
<P><FONT color=purple><FONT size=3></FONT></FONT> </P>
<P><FONT color=purple><FONT size=3></FONT></FONT> </P>
<P><FONT color=purple><FONT size=3>如不能顯示語法效果可貼去本站</FONT><A href="http://www.bunbun000.com/html/index.htm" target=_blank><FONT color=red size=3>語法測試板</FONT></A><FONT color=#0000ff size=3>試看</FONT></FONT></P>
<P><FONT color=purple></FONT> </P>
<P><FONT color=purple></FONT> </P>
<P><FONT color=purple></FONT> </P>
<P><FONT color=purple></FONT> </P>
<P><FONT color=purple>http://www.bunbunhk.com/logo.ico <<< 尾巴圖檔,可更改</FONT></P>
<P><FONT color=blue></FONT> </P>
<P><FONT color=blue></FONT> </P>
<P><FONT color=#0000ff></FONT> </P>
<P> </P>
<P><FONT color=blue></FONT> </P>
<P><FONT color=blue><div id="dot0" style="position: absolute; visibility: hidden; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div><BR><div id="dot1" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div><BR><div id="dot2" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div><BR><div id="dot3" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div><BR><div id="dot4" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div><BR><div id="dot5" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div><BR><div id="dot6" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div><BR><BR><SCRIPT LANGUAGE="JavaScript"><BR><!-- Begin<BR>var nDots = 7;<BR>var Xpos = 0;<BR>var Ypos = 0;<BR>// fixed time step, no relation to real time<BR>var DELTAT = .01;<BR>// size of one spring in pixels<BR>var SEGLEN = 10;<BR>// spring constant, stiffness of springs<BR>var SPRINGK = 10;<BR>// all the physics is bogus, just picked stuff to<BR>// make it look okay<BR>var MASS = 1;<BR>var GRAVITY = 50;<BR>var RESISTANCE = 10;<BR>// stopping criteria to prevent endless jittering<BR>// doesn't work when sitting on bottom since floor<BR>// doesn't push back so acceleration always as big<BR>// as gravity<BR>var STOPVEL = 0.1;<BR>var STOPACC = 0.1;<BR>var DOTSIZE = 11;<BR>// BOUNCE is percent of velocity retained when bounced<BR>var BOUNCE = 0.75;<BR>var isNetscape = navigator.appName=="Netscape";<BR>// always on for now, could be played with to<BR>// let dots fall to botton, get thrown, etc.<BR>var followmouse = true;<BR>var dots = new Array();<BR>init();<BR>function init() {<BR>var i = 0;<BR>for (i = 0; i < nDots; i++) {<BR>dots = new dot(i);<BR>}<BR>if (!isNetscape) {<BR>// I only know how to read the locations of the <BR>// <LI> items in IE<BR>//skip this for now<BR>// setInitPositions(dots)<BR>}<BR>// set their positions<BR>for (i = 0; i < nDots; i++) {<BR>dots.obj.left = dots.X;<BR>dots.obj.top = dots.Y;<BR>}<BR>if (isNetscape) {<BR>// start right away since they are positioned<BR>// at 0, 0<BR>startanimate();<BR>} else {<BR>// let dots sit there for a few seconds<BR>// sincey they're hiding on the real bullets<BR>setTimeout("startanimate()", 3000);<BR>}<BR>}<BR>function dot(i) {<BR>this.X = Xpos;<BR>this.Y = Ypos;<BR>this.dx = 0;<BR>this.dy = 0;<BR>if (isNetscape) {<BR>this.obj = eval("document.dot" + i);<BR>} else {<BR>this.obj = eval("dot" + i + ".style"<BR>}<BR>}<BR>function startanimate() {<BR>setInterval("animate()", 20);<BR>}<BR>// This is to line up the bullets with actual LI tags on the page<BR>function setInitPositions(dots) {<BR>// initialize dot positions to be on top <BR>// of the bullets in the <ul><BR>var startloc = document.all.tags("LI"<BR>var i = 0;<BR>for (i = 0; i < startloc.length && i < (nDots - 1); i++) {<BR>dots[i+1].X = startloc.offsetLeft<BR>startloc.offsetParent.offsetLeft - DOTSIZE;<BR>dots[i+1].Y = startloc.offsetTop +<BR>startloc.offsetParent.offsetTop + 2*DOTSIZE;<BR>}<BR>// put 0th dot above 1st (it is hidden)<BR>dots[0].X = dots[1].X;<BR>dots[0].Y = dots[1].Y - SEGLEN;<BR>}<BR>// just save mouse position for animate() to use<BR>function MoveHandler(e)<BR>{<BR>Xpos = e.pageX;<BR>Ypos = e.pageY; <BR>return true;<BR>}<BR>// just save mouse position for animate() to use<BR>function MoveHandlerIE() {<BR>Xpos = window.event.x;<BR>Ypos = window.event.y; <BR>}<BR>if (isNetscape) {<BR>document.captureEvents(Event.MOUSEMOVE);<BR>document.onMouseMove = MoveHandler;<BR>} else {<BR>document.onmousemove = MoveHandlerIE;<BR>}<BR>function vec(X, Y) {<BR>this.X = X;<BR>this.Y = Y;<BR>}<BR>// adds force in X and Y to spring for dot on dot[j]<BR>function springForce(i, j, spring) {<BR>var dx = (dots.X - dots[j].X);<BR>var dy = (dots.Y - dots[j].Y);<BR>var len = Math.sqrt(dx*dx + dy*dy);<BR>if (len > SEGLEN) {<BR>var springF = SPRINGK * (len - SEGLEN);<BR>spring.X += (dx / len) * springF;<BR>spring.Y += (dy / len) * springF;<BR>}<BR>}<BR>function animate() {<BR>// dots[0] follows the mouse,<BR>// though no dot is drawn there<BR>var start = 0;<BR>if (followmouse) {<BR>dots[0].X = Xpos;<BR>dots[0].Y = Ypos;<BR>start = 1;<BR>}<BR>for (i = start ; i < nDots; i++ ) {<BR>var spring = new vec(0, 0);<BR>if (i > 0) {<BR>springForce(i-1, i, spring);<BR>}<BR>if (i < (nDots - 1)) {<BR>springForce(i+1, i, spring);<BR>}<BR>// air resisitance/friction<BR>var resist = new vec(-dots.dx * RESISTANCE, -dots.dy * RESISTANCE);<BR>// compute new accel, including gravity<BR>var accel = new vec((spring.X + resist.X)/ MASS, (spring.Y + resist.Y)/ MASS + GRAVITY);<BR>// compute new velocity<BR>dots.dx += (DELTAT * accel.X);<BR>dots.dy += (DELTAT * accel.Y);<BR>// stop dead so it doesn't jitter when nearly still<BR>if (Math.abs(dots.dx) < STOPVEL &&<BR>Math.abs(dots.dy) < STOPVEL &&<BR>Math.abs(accel.X) < STOPACC &&<BR>Math.abs(accel.Y) < STOPACC) {<BR>dots.dx = 0;<BR>dots.dy = 0;<BR>}<BR>// move to new position<BR>dots.X += dots.dx;<BR>dots.Y += dots.dy;<BR>// get size of window<BR>var height, width;<BR>if (isNetscape) {<BR>height = window.innerHeight;<BR>width = window.innerWidth;<BR>} else {<BR>height = document.body.clientHeight;<BR>width = document.body.clientWidth;<BR>}<BR>// bounce of 3 walls (leave ceiling open)<BR>if (dots.Y >= height - DOTSIZE - 1) {<BR>if (dots.dy > 0) {<BR>dots.dy = BOUNCE * -dots.dy;<BR>}<BR>dots.Y = height - DOTSIZE - 1;<BR>}<BR>if (dots.X >= width - DOTSIZE) {<BR>if (dots.dx > 0) {<BR>dots.dx = BOUNCE * -dots.dx;<BR>}<BR>dots.X = width - DOTSIZE - 1;<BR>}<BR>if (dots.X < 0) {<BR>if (dots.dx < 0) {<BR>dots.dx = BOUNCE * -dots.dx;<BR>}<BR>dots.X = 0;<BR>}<BR>// move img to new position<BR>dots.obj.left = dots.X;<BR>dots.obj.top = dots.Y;<BR>}<BR>}<BR>// End --><BR></script> </FONT></P>