html & gt
& lthead & gt
& lttitle & gt網頁特效| linkweb.cn/js |-跟隨鼠標的酷炫三色帶
& lt/head & gt;& ltbody bgColor=#000000>。
& lt!-將以下代碼添加到
& lt腳本語言= " JavaScript " & gt
& lt!-
var a _ Colour = ' fff000
var b _ Colour = ' 00ff00
var c _ Colour = ' ff00ff
var Size = 120;
var YDummy=new Array(),XDummy = new Array(),xpos=0,ypos=0,this step = 0;步長= 0.6;
if (document.layers){
window.captureEvents(事件。MOUSEMOVE);
函數nsMouse(evnt){
xpos = window . pagey offset+evnt . pagex+6;
ypos = window . pagey offset+evnt . pagey+16;
}
window.onMouseMove = nsMouse
}
else if (document.all)
{
函數ieMouse(){
xpos = document . body . scroll left+event . x+6;
ypos = document . body . scroll top+event . y+16;
}
document.onmousemove = ieMouse
}
函數swirl(){
for(I = 0;我& lt3;i++)
{
YDummy[I]= ypos+Size * math . sin((1 * math . sin((this step)/10))+I * 2)* math . sin((this step)/4);
xdumid[I]= xpos+Size * math . cos((1 * math . sin((this step)/10))+I * 2)* math . sin((this step)/4);
}
this step+= step;
setTimeout('swirl()',10);
}
var金額= 10;
if (document.layers){
for(I = 0;我& lt金額;i++)
{
document . write(' & lt;layer name = NSA '+I+' top = 0 left = 0 width = '+I/2+' height = '+I/2+' bgcolor = '+a _ Colour+' & gt;& lt/layer & gt;');
document . write(' & lt;layer name = nsb '+I+' top = 0 left = 0 width = '+I/2+' height = '+I/2+' bgcolor = '+b _ Colour+' & gt;& lt/layer & gt;');
document . write(' & lt;layer name = NSC '+I+' top = 0 left = 0 width = '+I/2+' height = '+I/2+' bgcolor = '+c _ Colour+' & gt;& lt/layer & gt;');
}
}
else if (document.all){
document . write(' & lt;div id = " ODiv " style = " position:absolute;top:0px;left:0px " >;'
+' & lt;' div id = " IDiv " style = " position:relative " >);
for(I = 0;我& lt金額;i++)
{
document . write(' & lt;div id = x style = " position:absolute;top:0px;左:0px寬度:“+I/2+”;高度:“+I/2+”;背景:“+a _ Colour+”;font-size:'+I/2+' " & gt;& lt/div & gt;');
document . write(' & lt;div id = y style = " position:absolute;top:0px;左:0px寬度:“+I/2+”;高度:“+I/2+”;背景:“+b _ Colour+”;font-size:'+I/2+' " & gt;& lt/div & gt;');
document . write(' & lt;div id = z style = " position:absolute;top:0px;左:0px寬度:“+I/2+”;高度:“+I/2+”;背景:“+c _ Colour+”;font-size:'+I/2+' " & gt;& lt/div & gt;');
}
document . write(' & lt;/div & gt;& lt/div & gt;');
}
函數prepos(){
var ntscp = document.layers
var msie = document.all
if (document.layers){
for(I = 0;我& lt金額;i++)
{
如果(我& lt金額-1)
{
ntscp['nsa'+i]。top=ntscp['nsa'+(i+1)]。頂;ntscp['nsa'+i]。left=ntscp['nsa'+(i+1)]。左;
ntscp['nsb'+i]。top=ntscp['nsb'+(i+1)]。頂;ntscp['nsb'+i]。left=ntscp['nsb'+(i+1)]。左;
ntscp['nsc'+i]。top=ntscp['nsc'+(i+1)]。頂;ntscp['nsc'+i]。left=ntscp['nsc'+(i+1)]。左;
}
其他
{
ntscp['nsa'+i]。top = y dummy[0];ntscp['nsa'+i]。left = xdumid[0];
ntscp['nsb'+i]。top = YDummy[1];ntscp['nsb'+i]。left = xdument[1];
ntscp['nsc'+i]。top = YDummy[2];ntscp['nsc'+i]。left = xdument[2];
}
}
}
else if (document.all){
for(I = 0;我& lt金額;i++)
{
如果(我& lt金額-1)
{
msie . x[I]. style . top = msie . x[I+1]. style . top;msie . x[I]. style . left = msie . x[I+1]. style . left;
msie . y[I]. style . top = msie . y[I+1]. style . top;msie . y[I]. style . left = msie . y[I+1]. style . left;
msie . z[I]. style . top = msie . z[I+1]. style . top;msie . z[I]. style . left = msie . z[I+1]. style . left;
}
其他
{
msie . x[I]. style . top = YDummy[0];msie . x[I]. style . left = xdumid[0];
msie . y[I]. style . top = YDummy[1];msie . y[I]. style . left = xdumid[1];
msie . z[I]. style . top = YDummy[2];msie . z[I]. style . left = xdumid[2];
}
}
}
setTimeout("prepos()",10);
}
函數Start(){
漩渦(),前置()
}
window.onload = Start
//-& gt;
& lt/script & gt;
& lt/body & gt;& lt/html & gt;
跟隨鼠標非常逼真的彈性球。
& lthtml & gt
& lthead & gt
& lttitle & gt網頁特效| linkweb.cn/js |-非常逼真地跟隨鼠標的彈性球
& lt/head & gt;& ltbody & gt
& lt!-將以下代碼添加到
& ltDIV id=dot0
style = " HEIGHT:16;位置:絕對;可見性:隱藏;寬度:11;左:10;top:15 " >& ltIMG
height = 11 src = " images/bullet . gif " width = 11 & gt;& lt/DIV & gt;
& ltDIV id = dot 1 style = " HEIGHT:11px;位置:絕對;寬度:11px " >& ltIMG
height = 11 src = " images/bullet . gif " width = 11 & gt;& lt/DIV & gt;
& ltDIV id = dot 2 style = " HEIGHT:11px;位置:絕對;寬度:11px " >& ltIMG
height = 11 src = " images/bullet . gif " width = 11 & gt;& lt/DIV & gt;
& ltDIV id = dot 3 style = " HEIGHT:11px;位置:絕對;寬度:11px " >& ltIMG
height = 11 src = " images/bullet . gif " width = 11 & gt;& lt/DIV & gt;
& ltDIV id = dot 4 style = " HEIGHT:11px;位置:絕對;寬度:11px " >& ltIMG
height = 11 src = " images/bullet . gif " width = 11 & gt;& lt/DIV & gt;
& ltDIV id = dot 5 style = " HEIGHT:11px;位置:絕對;寬度:11px " >& ltIMG
height = 11 src = " images/bullet . gif " width = 11 & gt;& lt/DIV & gt;
& ltDIV id = dot 6 style = " HEIGHT:16;位置:絕對;寬度:11;左:10;top:15 " >& ltIMG
height = 11 src = " images/bullet . gif " width = 11 & gt;& lt/DIV & gt;
& lt腳本語言= JavaScript & gt
var nDots = 7;
var Xpos = 0;
var Ypos = 0;
var DELTAT = . 01;
var SEGLEN = 10;
var SPRINGK = 10;
var MASS = 1;
var x gravity = 0;
var YGRAVITY = 50
var電阻= 10;
var stop vel = 0.1;
var STOPACC = 0.1;
var DOTSIZE = 11;
var反彈= 0.75;
var isNetscape = navigator . appname = = " Netscape ";
var followmouse = true
var dots = new Array();
init();
函數init()
{
var I = 0;
for(I = 0;我& ltnDotsi++) {
dots[i] =新的點(I);
}
如果(!isNetscape) {
}
for(I = 0;我& ltnDotsi++) {
dots[i]左。x;
dots[I]obj . top = dots[I]。y;
}
if (isNetscape) {
startanimate();
}否則{
setTimeout("startanimate()",1000);
}
}
功能點(壹)
{
這個。X = Xpos
這個。Y = Ypos
this . dx = 0;
this . dy = 0;
if (isNetscape) {
this . obj = eval(" document . dot "+I);
}否則{
this.obj = eval("dot" + i +")。風格”);
}
}
函數startanimate() {
setInterval("animate()",20);
}
函數集初始位置(點)
{
var start loc = document . all . tags(" LI ");
var I = 0;
for(I = 0;我& ltstartloc.length & amp& amp我& lt(n dots-1);i++) {
dots[i+1]。X = startloc[i]。偏左
start loc[I]. offset parent . offset left-DOTSIZE;
dots[i+1]。Y = startloc[i]。offsetTop +
start loc[I]. offset parent . offsettop+2 * DOTSIZE;
}
點[0]。X =點[1]。x;
點[0]。Y = dots[1]。y-SEGLEN;
}
函數移動處理程序(e)
{
Xpos = e.pageX
Ypos = e.pageY
返回true
}
函數MoveHandlerIE() {
xpos = window . event . x+document . body . scroll left;
ypos = window . event . y+document . body . scroll top;
}
if (isNetscape) {
document.captureEvents(事件。MOUSEMOVE);
document . onmousemove = move handler;
}否則{
document . onmousemove = MoveHandlerIE;
}
函數vec(X,Y)
{
這個。X = X
這個。Y = Y
}
函數彈簧力(I,j,彈簧)
{
var dx = (dots[i].x點[j]。x);
var dy = (dots[i].y點[j]。y);
var len = math . sqrt(dx * dx+dy * dy);
if(len & gt;SEGLEN) {
var springF = SPRINGK *(len-SEGLEN);
春天。x+=(dx/len)* springF;
春天。y+=(dy/len)* springF;
}
}
函數animate() {
var start = 0;
if (followmouse) {
點[0]。X = Xpos
點[0]。Y = Ypos
start = 1;
}
for(I = start;我& ltnDotsi++ ) {
var spring = new vec(0,0);
如果(i & gt0) {
springForce(i-1,I,spring);
}
如果(我& lt(nDots - 1)) {
springForce(i+1,I,spring);
}
var resist = new vec(-dots[i].dx *電阻,
-圓點[i]。dy *電阻);
var accel = new vec((spring。X +抗。x)/質量+x重力,
(春天。Y +抗拒。y)/MASS+YGRAVITY);
圓點[i]。dx += (DELTAT * accel。x);
圓點[i]。dy += (DELTAT * accel。y);
if (Math.abs(dots[i].dx)& lt;STOPVEL & amp& amp
Math.abs(dots[i].dy)& lt;STOPVEL & amp& amp
Math.abs(accel。x)& lt;STOPACC & amp& amp
Math.abs(accel。y)& lt;STOPACC) {
圓點[i]。dx = 0;
圓點[i]。dy = 0;
}
圓點[i]。X += dots[i]。dx;
圓點[i]。Y += dots[i]。dy;
不同高度、寬度;
if (isNetscape) {
height = window . inner height+window . pageyoffset;
width = window . inner width+window . pagexoffset;
}否則{
height = document . body . client height+document . body . scroll top;
width = document . body . client width+document . body . scroll left;
}
如果(點[i]。Y & gt= height - DOTSIZE - 1) {
如果(點[i]。dy & gt0) {
圓點[i]。dy = BOUNCE * -dots[i]。dy;
}
圓點[i]。y = height-DOTSIZE-1;
}
如果(點[i]。X & gt=寬度-點大小){
如果(點[i]。dx & gt0) {
圓點[i]。dx = BOUNCE * -dots[i]。dx;
}
圓點[i]。x = width-DOTSIZE-1;
}
如果(點[i]。X & lt0) {
如果(點[i]。dx & lt0) {
圓點[i]。dx = BOUNCE * -dots[i]。dx;
}
圓點[i]。x = 0;
}
dots[i]左。x;
dots[I]obj . top = dots[I]。y;
}
}
& lt/SCRIPT & gt;
& lt/body & gt;& lt/html & gt;
這裏太小了,放不下這麽多。
/jave_mouse/29051032.htm
他們有很多人。如果不想鏈接,就看那兩個。