查看完整版本: 鴨仔跟著游滑鼠游標特效

24-1-2010 09:13

鴨仔跟著游滑鼠游標特效

<br><br><br><br><br><br>


可將語法內之圖檔  <br><br>

[url]http://www.bunbunhk.com/logo.ico[/url]

<br><br>

更改為其他圖片如鴨仔雞仔等,四個圖檔可更改為不同圖樣


<br><br><br><br><br><br>








<!--鴨鴨游標_開始-->
<div id="dot0" style="position: absolute; visibility: hidden;">
</div>
<div id="dot1" style="position: absolute;">
<img src="http://www.bunbunhk.com/logo.ico"></div>
<div id="dot2" style="position: absolute;">
<img src="http://www.bunbunhk.com/logo.ico"></div>
<div id="dot3" style="position: absolute;">
<img src="http://www.bunbunhk.com/logo.ico"></div>
<div id="dot4" style="position: absolute;">
<img src="http://www.bunbunhk.com/logo.ico"></div>
<script language="JavaScript">
<!--
var nDots = 5;
if (document.all&&window.print)
document.body.style.cssText="overflow-x:hidden;overflow-y:scroll"
var Xpos = 0;
var Ypos = 0;
var DELTAT = .01;
var SEGLEN = 10;
var SPRINGK = 10;
var MASS = 1;
var GRAVITY = 50;
var RESISTANCE = 10;
var STOPVEL = 0.1;
var STOPACC = 0.1;
var DOTSIZE = 11;
var BOUNCE = 0.75;
var isNetscape = navigator.appName=="Netscape";
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) {
}
for (i = 0; i < nDots; i++) {
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
if (isNetscape) {
startanimate();
} else {
setTimeout("startanimate()", 2000);
}
}
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);
}
function setInitPositions(dots)
{
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;
}
dots[0].X = dots[1].X;
dots[0].Y = dots[1].Y - SEGLEN;
}
function MoveHandler(e)
{
Xpos = e.pageX;
Ypos = e.pageY;
return true;
}
function MoveHandlerIE() {
Xpos = window.event.x + document.body.scrollLeft;
Ypos = window.event.y + document.body.scrollTop;
}
if (isNetscape) {
document.captureEvents(Event.MOUSEMOVE);
document.onMouseMove = MoveHandler;
} else {
document.onmousemove = MoveHandlerIE;
}
function vec(X, Y)
{
this.X = X;
this.Y = Y;
}
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() {
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);
}
var resist = new vec(-dots[i].dx * RESISTANCE,
-dots[i].dy * RESISTANCE);
var accel = new vec((spring.X + resist.X)/ MASS,
(spring.Y + resist.Y)/ MASS + GRAVITY);
dots[i].dx += (DELTAT * accel.X);
dots[i].dy += (DELTAT * accel.Y);
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;
}
dots[i].X += dots[i].dx;
dots[i].Y += dots[i].dy;
var height, width;
if (isNetscape) {
height = window.innerHeight + document.scrollTop;
width = window.innerWidth + document.scrollLeft;
} else {
height = document.body.clientHeight + document.body.scrollTop;
width = document.body.clientWidth + document.body.scrollLeft;
}
// 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;
}
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
}
-->
</script>
<!--鴨鴨游標_結束-->












<DIV style="POSITION: absolute; VISIBILITY: hidden" id=dot0></DIV><BR>&lt;div id="dot0" style="position: absolute; visibility: hidden;"&gt;<BR>&lt;/div&gt; <BR>&lt;div id="dot1" style="position: absolute;"&gt;<BR>&lt;img src="<A href='http://www.bunbunhk.com/logo.ico"></div'>http://www.bunbunhk.com/logo.ico"&gt;&lt;/div</A>&gt; <BR>&lt;div id="dot2" style="position: absolute;"&gt;<BR>&lt;img src="<A href='http://www.bunbunhk.com/logo.ico"></div'>http://www.bunbunhk.com/logo.ico"&gt;&lt;/div</A>&gt; <BR>&lt;div id="dot3" style="position: absolute;"&gt;<BR>&lt;img src="<A href='http://www.bunbunhk.com/logo.ico"></div'>http://www.bunbunhk.com/logo.ico"&gt;&lt;/div</A>&gt; <BR>&lt;div id="dot4" style="position: absolute;"&gt;<BR>&lt;img src="<A href='http://www.bunbunhk.com/logo.ico"></div'>http://www.bunbunhk.com/logo.ico"&gt;&lt;/div</A>&gt; <BR>&lt;script language="JavaScript"&gt;<BR>&lt;!--<BR>var nDots = 5; <BR>if (document.all&&window.print) <BR>document.body.style.cssText="overflow-x:hidden;overflow-y:scroll" <BR>var Xpos = 0; <BR>var Ypos = 0; <BR>var DELTAT = .01; <BR>var SEGLEN = 10; <BR>var SPRINGK = 10; <BR>var MASS = 1; <BR>var GRAVITY = 50; <BR>var RESISTANCE = 10; <BR>var STOPVEL = 0.1; <BR>var STOPACC = 0.1; <BR>var DOTSIZE = 11; <BR>var BOUNCE = 0.75; <BR>var isNetscape = navigator.appName=="Netscape"; <BR>var followmouse = true; <BR>var dots = new Array(); <BR>init(); <BR>function init() <BR>{ <BR>var i = 0; <BR>for (i = 0; i &lt; nDots; i++) { <BR>dots[i] = new dot(i); <BR>} <BR>if (!isNetscape) { <BR>} <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>startanimate(); <BR>} else { <BR>setTimeout("startanimate()", 2000); <BR>} <BR>} <BR>function dot(i) <BR>{ <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>function setInitPositions(dots) <BR>{ <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>dots[0].X = dots[1].X; <BR>dots[0].Y = dots[1].Y - SEGLEN; <BR>} <BR>function MoveHandler(e) <BR>{ <BR>Xpos = e.pageX; <BR>Ypos = e.pageY; <BR>return true; <BR>} <BR>function MoveHandlerIE() { <BR>Xpos = window.event.x + document.body.scrollLeft; <BR>Ypos = window.event.y + document.body.scrollTop; <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>{ <BR>this.X = X; <BR>this.Y = Y; <BR>} <BR>function springForce(i, j, spring) <BR>{ <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>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>var resist = new vec(-dots[i].dx * RESISTANCE, <BR>-dots[i].dy * RESISTANCE); <BR>var accel = new vec((spring.X + resist.X)/ MASS, <BR>(spring.Y + resist.Y)/ MASS + GRAVITY); <BR>dots[i].dx += (DELTAT * accel.X); <BR>dots[i].dy += (DELTAT * accel.Y); <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>dots[i].X += dots[i].dx; <BR>dots[i].Y += dots[i].dy; <BR>var height, width; <BR>if (isNetscape) { <BR>height = window.innerHeight + document.scrollTop; <BR>width = window.innerWidth + document.scrollLeft; <BR>} else { <BR>height = document.body.clientHeight + document.body.scrollTop; <BR>width = document.body.clientWidth + document.body.scrollLeft; <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>dots[i].obj.left = dots[i].X; <BR>dots[i].obj.top = dots[i].Y; <BR>} <BR>}<BR>--&gt;<BR>&lt;/script&gt;<BR>

25-5-2013 15:58

複製上列語法

<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;">
</div>
<div id="dot1" style="position: absolute;">
<img src="http://www.bunbunhk.com/logo.ico"></div>
<div id="dot2" style="position: absolute;">
<img src="http://www.bunbunhk.com/logo.ico"></div>
<div id="dot3" style="position: absolute;">
<img src="http://www.bunbunhk.com/logo.ico"></div>
<div id="dot4" style="position: absolute;">
<img src="http://www.bunbunhk.com/logo.ico"></div>
<script language="JavaScript">
<!--
var nDots = 5;
if (document.all&&window.print)
document.body.style.cssText="overflow-x:hidden;overflow-y:scroll"
var Xpos = 0;
var Ypos = 0;
var DELTAT = .01;
var SEGLEN = 10;
var SPRINGK = 10;
var MASS = 1;
var GRAVITY = 50;
var RESISTANCE = 10;
var STOPVEL = 0.1;
var STOPACC = 0.1;
var DOTSIZE = 11;
var BOUNCE = 0.75;
var isNetscape = navigator.appName=="Netscape";
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) {
}
for (i = 0; i < nDots; i++) {
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
if (isNetscape) {
startanimate();
} else {
setTimeout("startanimate()", 2000);
}
}
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);
}
function setInitPositions(dots)
{
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;
}
dots[0].X = dots[1].X;
dots[0].Y = dots[1].Y - SEGLEN;
}
function MoveHandler(e)
{
Xpos = e.pageX;
Ypos = e.pageY;
return true;
}
function MoveHandlerIE() {
Xpos = window.event.x + document.body.scrollLeft;
Ypos = window.event.y + document.body.scrollTop;
}
if (isNetscape) {
document.captureEvents(Event.MOUSEMOVE);
document.onMouseMove = MoveHandler;
} else {
document.onmousemove = MoveHandlerIE;
}
function vec(X, Y)
{
this.X = X;
this.Y = Y;
}
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() {
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);
}
var resist = new vec(-dots[i].dx * RESISTANCE,
-dots[i].dy * RESISTANCE);
var accel = new vec((spring.X + resist.X)/ MASS,
(spring.Y + resist.Y)/ MASS + GRAVITY);
dots[i].dx += (DELTAT * accel.X);
dots[i].dy += (DELTAT * accel.Y);
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;
}
dots[i].X += dots[i].dx;
dots[i].Y += dots[i].dy;
var height, width;
if (isNetscape) {
height = window.innerHeight + document.scrollTop;
width = window.innerWidth + document.scrollLeft;
} else {
height = document.body.clientHeight + document.body.scrollTop;
width = document.body.clientWidth + document.body.scrollLeft;
}
// 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;
}
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
}
-->
</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]
查看完整版本: 鴨仔跟著游滑鼠游標特效