查看完整版本: 拖著尾巴滑鼠游標

10-6-2012 09:15

拖著尾巴滑鼠游標

<P><FONT color=purple><FONT size=3></FONT></FONT>&nbsp;</P>
<P><FONT color=purple><FONT size=3></FONT></FONT>&nbsp;</P>
<P><FONT color=purple><FONT size=3></FONT></FONT>&nbsp;</P>
<P><FONT color=purple><FONT size=3></FONT></FONT>&nbsp;</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>&nbsp;</P>
<P><FONT color=purple></FONT>&nbsp;</P>
<P><FONT color=purple></FONT>&nbsp;</P>
<P><FONT color=purple></FONT>&nbsp;</P>
<P><FONT color=purple>http://www.bunbunhk.com/logo.ico &lt;&lt;&lt; 尾巴圖檔,可更改</FONT></P>
<P><FONT color=blue></FONT>&nbsp;</P>
<P><FONT color=blue></FONT>&nbsp;</P>
<P><FONT color=#0000ff></FONT>&nbsp;</P>
<P>&nbsp;</P>
<P><FONT color=blue></FONT>&nbsp;</P>
<P><FONT color=blue>&lt;div id="dot0" style="position: absolute; visibility: hidden; height: 11; width: 11;"&gt;&lt;img src="http://www.bunbunhk.com/logo.ico" height=11 width=11&gt;&lt;/div&gt;<BR>&lt;div id="dot1" style="position: absolute; height: 11; width: 11;"&gt;&lt;img src="http://www.bunbunhk.com/logo.ico" height=11 width=11&gt;&lt;/div&gt;<BR>&lt;div id="dot2" style="position: absolute; height: 11; width: 11;"&gt;&lt;img src="http://www.bunbunhk.com/logo.ico" height=11 width=11&gt;&lt;/div&gt;<BR>&lt;div id="dot3" style="position: absolute; height: 11; width: 11;"&gt;&lt;img src="http://www.bunbunhk.com/logo.ico" height=11 width=11&gt;&lt;/div&gt;<BR>&lt;div id="dot4" style="position: absolute; height: 11; width: 11;"&gt;&lt;img src="http://www.bunbunhk.com/logo.ico" height=11 width=11&gt;&lt;/div&gt;<BR>&lt;div id="dot5" style="position: absolute; height: 11; width: 11;"&gt;&lt;img src="http://www.bunbunhk.com/logo.ico" height=11 width=11&gt;&lt;/div&gt;<BR>&lt;div id="dot6" style="position: absolute; height: 11; width: 11;"&gt;&lt;img src="http://www.bunbunhk.com/logo.ico" height=11 width=11&gt;&lt;/div&gt;<BR><BR>&lt;SCRIPT LANGUAGE="JavaScript"&gt;<BR>&lt;!-- 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 &lt; nDots; i++) {<BR>dots[i] = new dot(i);<BR>}<BR>if (!isNetscape) {<BR>// I only know how to read the locations of the <BR>// &lt;LI&gt; items in IE<BR>//skip this for now<BR>// setInitPositions(dots)<BR>}<BR>// set their positions<BR>for (i = 0; i &lt; nDots; i++) {<BR>dots[i].obj.left = dots[i].X;<BR>dots[i].obj.top = dots[i].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 &lt;ul&gt;<BR>var startloc = document.all.tags("LI");<BR>var i = 0;<BR>for (i = 0; i &lt; startloc.length && i &lt; (nDots - 1); i++) {<BR>dots[i+1].X = startloc[i].offsetLeft<BR>startloc[i].offsetParent.offsetLeft - DOTSIZE;<BR>dots[i+1].Y = startloc[i].offsetTop +<BR>startloc[i].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[i] on dot[j]<BR>function springForce(i, j, spring) {<BR>var dx = (dots[i].X - dots[j].X);<BR>var dy = (dots[i].Y - dots[j].Y);<BR>var len = Math.sqrt(dx*dx + dy*dy);<BR>if (len &gt; 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 &lt; nDots; i++ ) {<BR>var spring = new vec(0, 0);<BR>if (i &gt; 0) {<BR>springForce(i-1, i, spring);<BR>}<BR>if (i &lt; (nDots - 1)) {<BR>springForce(i+1, i, spring);<BR>}<BR>// air resisitance/friction<BR>var resist = new vec(-dots[i].dx * RESISTANCE, -dots[i].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[i].dx += (DELTAT * accel.X);<BR>dots[i].dy += (DELTAT * accel.Y);<BR>// stop dead so it doesn't jitter when nearly still<BR>if (Math.abs(dots[i].dx) &lt; STOPVEL &&<BR>Math.abs(dots[i].dy) &lt; STOPVEL &&<BR>Math.abs(accel.X) &lt; STOPACC &&<BR>Math.abs(accel.Y) &lt; STOPACC) {<BR>dots[i].dx = 0;<BR>dots[i].dy = 0;<BR>}<BR>// move to new position<BR>dots[i].X += dots[i].dx;<BR>dots[i].Y += dots[i].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[i].Y &gt;= height - DOTSIZE - 1) {<BR>if (dots[i].dy &gt; 0) {<BR>dots[i].dy = BOUNCE * -dots[i].dy;<BR>}<BR>dots[i].Y = height - DOTSIZE - 1;<BR>}<BR>if (dots[i].X &gt;= width - DOTSIZE) {<BR>if (dots[i].dx &gt; 0) {<BR>dots[i].dx = BOUNCE * -dots[i].dx;<BR>}<BR>dots[i].X = width - DOTSIZE - 1;<BR>}<BR>if (dots[i].X &lt; 0) {<BR>if (dots[i].dx &lt; 0) {<BR>dots[i].dx = BOUNCE * -dots[i].dx;<BR>}<BR>dots[i].X = 0;<BR>}<BR>// move img to new position<BR>dots[i].obj.left = dots[i].X;<BR>dots[i].obj.top = dots[i].Y;<BR>}<BR>}<BR>// End --&gt;<BR>&lt;/script&gt; </FONT></P>

25-5-2013 16:05

複製上列語法

<form name="copy">
<textarea cols="40" name="txt" rows="4" style="BACKGROUND-COLOR:#ffffff; COLOR:#000000; FONT-SIZE:9pt">
<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>
<div id="dot1" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div>
<div id="dot2" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div>
<div id="dot3" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div>
<div id="dot4" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div>
<div id="dot5" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div>
<div id="dot6" style="position: absolute; height: 11; width: 11;"><img src="http://www.bunbunhk.com/logo.ico" height=11 width=11></div>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var nDots = 7;
var Xpos = 0;
var Ypos = 0;
// fixed time step, no relation to real time
var DELTAT = .01;
// size of one spring in pixels
var SEGLEN = 10;
// spring constant, stiffness of springs
var SPRINGK = 10;
// all the physics is bogus, just picked stuff to
// make it look okay
var MASS = 1;
var GRAVITY = 50;
var RESISTANCE = 10;
// stopping criteria to prevent endless jittering
// doesn't work when sitting on bottom since floor
// doesn't push back so acceleration always as big
// as gravity
var STOPVEL = 0.1;
var STOPACC = 0.1;
var DOTSIZE = 11;
// BOUNCE is percent of velocity retained when bounced
var BOUNCE = 0.75;
var isNetscape = navigator.appName=="Netscape";
// always on for now, could be played with to
// let dots fall to botton, get thrown, etc.
var followmouse = true;
var dots = new Array();
init();
function init() {
var i = 0;
for (i = 0; i < nDots; i++) {
dots[i] = new dot(i);
}
if (!isNetscape) {
// I only know how to read the locations of the
// <LI> items in IE
//skip this for now
// setInitPositions(dots)
}
// set their positions
for (i = 0; i < nDots; i++) {
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
if (isNetscape) {
// start right away since they are positioned
// at 0, 0
startanimate();
} else {
// let dots sit there for a few seconds
// sincey they're hiding on the real bullets
setTimeout("startanimate()", 3000);
}
}
function dot(i) {
this.X = Xpos;
this.Y = Ypos;
this.dx = 0;
this.dy = 0;
if (isNetscape) {
this.obj = eval("document.dot" + i);
} else {
this.obj = eval("dot" + i + ".style");
}
}
function startanimate() {
setInterval("animate()", 20);
}
// This is to line up the bullets with actual LI tags on the page
function setInitPositions(dots) {
// initialize dot positions to be on top
// of the bullets in the <ul>
var startloc = document.all.tags("LI");
var i = 0;
for (i = 0; i < startloc.length && i < (nDots - 1); i++) {
dots[i+1].X = startloc[i].offsetLeft
startloc[i].offsetParent.offsetLeft - DOTSIZE;
dots[i+1].Y = startloc[i].offsetTop +
startloc[i].offsetParent.offsetTop + 2*DOTSIZE;
}
// put 0th dot above 1st (it is hidden)
dots[0].X = dots[1].X;
dots[0].Y = dots[1].Y - SEGLEN;
}
// just save mouse position for animate() to use
function MoveHandler(e)
{
Xpos = e.pageX;
Ypos = e.pageY;
return true;
}
// just save mouse position for animate() to use
function MoveHandlerIE() {
Xpos = window.event.x;
Ypos = window.event.y;
}
if (isNetscape) {
document.captureEvents(Event.MOUSEMOVE);
document.onMouseMove = MoveHandler;
} else {
document.onmousemove = MoveHandlerIE;
}
function vec(X, Y) {
this.X = X;
this.Y = Y;
}
// adds force in X and Y to spring for dot[i] on dot[j]
function springForce(i, j, spring) {
var dx = (dots[i].X - dots[j].X);
var dy = (dots[i].Y - dots[j].Y);
var len = Math.sqrt(dx*dx + dy*dy);
if (len > SEGLEN) {
var springF = SPRINGK * (len - SEGLEN);
spring.X += (dx / len) * springF;
spring.Y += (dy / len) * springF;
}
}
function animate() {
// dots[0] follows the mouse,
// though no dot is drawn there
var start = 0;
if (followmouse) {
dots[0].X = Xpos;
dots[0].Y = Ypos;
start = 1;
}
for (i = start ; i < nDots; i++ ) {
var spring = new vec(0, 0);
if (i > 0) {
springForce(i-1, i, spring);
}
if (i < (nDots - 1)) {
springForce(i+1, i, spring);
}
// air resisitance/friction
var resist = new vec(-dots[i].dx * RESISTANCE, -dots[i].dy * RESISTANCE);
// compute new accel, including gravity
var accel = new vec((spring.X + resist.X)/ MASS, (spring.Y + resist.Y)/ MASS + GRAVITY);
// compute new velocity
dots[i].dx += (DELTAT * accel.X);
dots[i].dy += (DELTAT * accel.Y);
// stop dead so it doesn't jitter when nearly still
if (Math.abs(dots[i].dx) < STOPVEL &&
Math.abs(dots[i].dy) < STOPVEL &&
Math.abs(accel.X) < STOPACC &&
Math.abs(accel.Y) < STOPACC) {
dots[i].dx = 0;
dots[i].dy = 0;
}
// move to new position
dots[i].X += dots[i].dx;
dots[i].Y += dots[i].dy;
// get size of window
var height, width;
if (isNetscape) {
height = window.innerHeight;
width = window.innerWidth;
} else {
height = document.body.clientHeight;
width = document.body.clientWidth;
}
// bounce of 3 walls (leave ceiling open)
if (dots[i].Y >= height - DOTSIZE - 1) {
if (dots[i].dy > 0) {
dots[i].dy = BOUNCE * -dots[i].dy;
}
dots[i].Y = height - DOTSIZE - 1;
}
if (dots[i].X >= width - DOTSIZE) {
if (dots[i].dx > 0) {
dots[i].dx = BOUNCE * -dots[i].dx;
}
dots[i].X = width - DOTSIZE - 1;
}
if (dots[i].X < 0) {
if (dots[i].dx < 0) {
dots[i].dx = BOUNCE * -dots[i].dx;
}
dots[i].X = 0;
}
// move img to new position
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
}
// End -->
</script>
</textarea><br>
<input onclick="javascript:this.form.txt.focus();this.form.txt.select();" type="button" value="全選">
</form>

<br>

<script type="text/javascript"><!--
google_ad_client = "ca-pub-4078143172638881";
/* 336X280 */
google_ad_slot = "3268225205";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
頁: [1]
查看完整版本: 拖著尾巴滑鼠游標