当前位置:酷百书>百科知识>鼠标跟随文字代码

鼠标跟随文字代码

2023-08-24 01:06:50 编辑:join 浏览量:598

鼠标跟随文字代码

鼠标跟随文字代码

鼠标特效篇--文本跟随鼠标鼠标特效篇--文本跟随鼠标var x,y

var step=18

var index=0

var message="鼠标特效篇--文本跟随鼠标!!"

message=message.split("")

var xpos=new Array()

for (i=0;i<=message.length-1;i++) { xpos[i]=-50 }

var ypos=new Array()

for (i=0;i<=message.length-1;i++) { ypos[i]=-200 }

function MouseText() {

if (index==1 && document.all) {

for (i=message.length-1; i>=1; i--) { xpos[i]=xpos[i-1]+step; ypos[i]=ypos[i-1] }

xpos=x+step

ypos=y

for (i=0; i}

else if (index==1 && document.layers) {

for (i=message.length-1; i>=1; i--) { xpos[i]=xpos[i-1]+step; ypos[i]=ypos[i-1] }

xpos=x+step

ypos=y

for (i=0; i}

var timer=setTimeout("MouseText()",30)

}

function MouseScroll(e){

x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX

y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY

index=1

}

for (i=0;i<=message.length-1;i++) {

document.write("")

document.write(message[i])

document.write("")

}

if (document.layers){ document.captureEvents(Event.mousemove);}

document.onmousemove = MouseScroll;

.spanstyle { color: #ff0033; font-family: 宋体; font-size: 10pt; position: absolute; top: -50px; visibility: visible}

document.write('document.write('');

document.write('

var msg='欢迎光临我的网站!';

var font='宋体';

var size=2;

var color='#996633';

var speed=.2;

var rotation=.2;

var ns=(document.layers);

var ie=(document.all);

var msg=msg.split('');

var n=msg.length;

var a=size*15;

var currStep=0;

var ymouse=0;

var xmouse=0;

var scrll=0;

var props="";

if (ie)

window.pageYOffset=0

if (ns){

for (i=0; i < n; i++)

document.write(''+props+msg[i]+''); }

if (ie){

document.write('

');for (i=0; i < n; i++)

document.write('

'+props+msg[i]+'

');document.write('

'); }(ns)?window.captureEvents(Event.MOUSEMOVE):0;

function Mouse(evnt){

ymouse = (ns)?evnt.pageY+20-(window.pageYOffset):event.y;

xmouse = (ns)?evnt.pageX+20:event.x-20;

}

if (ns||ie)

(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;

y=new Array();

x=new Array();

Y=new Array();

X=new Array();

for (i=0; i < n; i++){

y[i]=0;

x[i]=0;

Y[i]=0;

X[i]=0;}

function makecircle(){

if (ie) outer.style.top=document.body.scrollTop;

currStep-=rotation;

for (i=0; i < n; i++){

var d=(ns)?document.layers['nsmsg'+i]:iemsg[i].style;

d.top=y[i]+a*Math.sin((currStep+i*1)/3.8)+window.pageYOffset-15;

d.left=x[i]+a*Math.cos((currStep+i*1)/3.8)*2; }}

function drag(){

scrll=(ns)?window.pageYOffset:0;

y=Math.round(Y+=((ymouse)-Y)*speed);

x=Math.round(X+=((xmouse)-X)*speed);

for (var i=1; i < n; i++){

y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);

x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed); }

makecircle();

setTimeout('drag()',10);}

if (ns||ie)window.onload=drag;

http://www.yesky.com/imagesnew/software/jscript/index.html这里有很多特效!你自己看看先!

标签:鼠标,代码,跟随

版权声明:文章由 酷百书 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.kubaishu.com/article/359022.html
热门文章