2008年8月29日

跟随鼠标的竖的文字

代码效果:跟随鼠标的竖的文字


代码如下:

<!--将以下代码加入HTML的<Body></Body>之间--><br /><br /><SCRIPT language=JavaScript><br /><!--<br /><br />function MM_goToURL() { //v3.0<br /> var i, args=MM_goToURL.arguments; document.MM_returnValue = false;<br /> for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");<br />}<br />function JM_cc(ob){<br />var obj=MM_findObj(ob); if (obj) { <br />obj.select();js=obj.createTextRange();js.execCommand("Copy");}<br />}<br /><br />function MM_findObj(n, d) { //v4.0<br /> var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {<br /> d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}<br /> if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];<br /> for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);<br /> if(!x && document.getElementById) x=document.getElementById(n); return x;<br />}<br />//--><br /></SCRIPT><br /><br /> <SCRIPT language=JavaScript1.2><br /><!--<br /><br />/*<br />Cursor Trailer II (By Kurt at kurt.grigg@virgin.net)<br />Modified and featured on Dynamicdrive.com<br />For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com<br />*/<br /><br />var message='在这里输入文字内容';<br />var messagecolor='000000';<br /><br />//Enter number of seconds for message to display (0=perpetual)<br />var dismissafter=0<br /><br />///no need to edit below/////////<br />var amount=5,ypos=0,xpos=0,Ay=0,Ax=0,By=0,Bx=0,Cy=0,Cx=0,Dy=0,Dx=0,Ey=0,Ex=0;<br />if (document.layers){<br />for (i = 0; i < amount; i++)<br />{document.write('<layer name=ns'+i+' top=0 left=0><font face="Courier New" size=3 color='+messagecolor+'>'+message+'</font></layer>')}<br />window.captureEvents(Event.MOUSEMOVE);<br />function nsmouse(evnt){xpos = evnt.pageX;ypos = evnt.pageY;makefollow()}<br />}<br />else if (document.all){<br />document.write("<div id='outer' style='position:absolute;top:0px;left:0px'>");<br />document.write("<div id='inner' style='position:relative'>");<br />for (i = 0; i < amount; i++) <br />{document.write('<div id="text"'+i+' style="position:absolute;top:0px;left:0px;font-family:Courier New;font-size:16px;color:'+messagecolor+'">'+message+'</div>')}<br />document.write("</div>");<br />document.write("</div>");<br />function iemouse(){ypos = document.body.scrollTop + event.y;xpos = document.body.scrollLeft + event.x;makefollow()}<br />}<br />function makefollow(){<br />if (document.layers){<br />document.layers["ns0"].top=ay;document.layers["ns0"].left=ax;<br />document.layers["ns1"].top=by;document.layers["ns1"].left=bx;<br />document.layers["ns2"].top=cy;document.layers["ns2"].left=cx;<br />document.layers["ns3"].top=Dy;document.layers["ns3"].left=Dx;<br />document.layers["ns4"].top=Ey;document.layers["ns4"].left=Ex;<br />}<br />else if (document.all){<br />outer.all.inner.all[0].style.pixelTop=ay;outer.all.inner.all[0].style.pixelLeft=ax;<br />outer.all.inner.all[1].style.pixelTop=by;outer.all.inner.all[1].style.pixelLeft=bx;<br />outer.all.inner.all[2].style.pixelTop=cy;outer.all.inner.all[2].style.pixelLeft=cx;<br />outer.all.inner.all[3].style.pixelTop=Dy;outer.all.inner.all[3].style.pixelLeft=Dx;<br />outer.all.inner.all[4].style.pixelTop=Ey;outer.all.inner.all[4].style.pixelLeft=Ex;<br />}<br />}<br />function move(){<br />if (dismissafter!=0)<br />setTimeout("hidetrail()",dismissafter*1000)<br /><br />if (document.layers){window.onMouseMove = nsmouse}<br />else if (document.all){window.document.onmousemove = iemouse}<br />ey = Math.round(Ey+=((ypos+20)-Ey)*2/2);ex = Math.round(Ex+=((xpos+20)-Ex)*2/2);<br />dy = Math.round(Dy+=(ey - Dy)*2/4);dx = Math.round(Dx+=(ex - Dx)*2/4);<br />cy = Math.round(Cy+=(dy - Cy)*2/6);cx = Math.round(Cx+=(dx - Cx)*2/6);<br />by = Math.round(By+=(cy - By)*2/8);bx = Math.round(Bx+=(cx - Bx)*2/8);<br />ay = Math.round(Ay+= (by - Ay)*2/10);ax = Math.round(Ax+= (bx - Ax)*2/10);<br />makefollow();<br />jumpstart=setTimeout('move()',10);<br />}<br /><br />function hidetrail(){<br />if (document.all){<br />for (i2=0;i2<amount;i2++){<br />outer.all.inner.all[i2].style.visibility="hidden"<br />clearTimeout(jumpstart)<br />}<br />}<br />else if (document.layers){<br />for (i2=0;i2<amount;i2++){<br />temp="ns"+i2<br />document.layers[temp].visibility="hide"<br />clearTimeout(jumpstart)<br />}<br />}<br />}<br /><br />window.onload=move;<br />//--><br /></SCRIPT><br />

1 条评论:

风释 说...

由于编辑器的问题,如果代码无法显示请连接

http://jiaoliudi.blog.hexun.com/cate.aspx?cateid=732507&cate=%bf%d5%bc%e4%bd%a8%c9%e8