书籍教程网站地图
位置于:书籍教程
首页
>>
网页设计
>>
网页特效
>>正文
跟随鼠标的发光文字
跟随鼠标的发光文字
下面为脚本显示区
第一步,在<HEAD>区加入以下代码:
<script><!--var message = "网 络 红 尘:www.红 尘.net",bgcolor="ffffff";message=message.split(""); var times=message.length;var x,y,xspace,yspace,speed,colorv="FFFFFF";var xpos=new Array(),ypos=new Array();for (i=0;i<=times-1;i++)xpos[i]=-50;for (i=0;i<=times.length-1;i++)ypos[i]=-50;var flag=false,Pcolorstyle=3,runflag=false;var cyclecolor=new Array(times),runcolor=new Array(times);var keycolor=0,randkey=-1,basestep=0,keycstate=true;function preset(xval,yval,spval,xreval,yreval){ xspace=xval*xreval;yspace=yval*yreval;speed=spval;bgcolor=(document.bgColor.length == 7)?document.bgColor.substring(1,7):"ffffff";makecolor();}function makecolor(){//make a color cycleif (Pcolorstyle > 0){hexa = new Array(16);for(var i = 0; i < 10; i++)hexa[i] = i;hexa[10]="a"; hexa[11]="b"; hexa[12]="c";hexa[13]="d"; hexa[14]="e"; hexa[15]="f";var alycolor=new Array(parseInt("0x"+colorv.substring(0,2)),parseInt("0x"+colorv.substring(2,4)),parseInt("0x"+colorv.substring(4,6)));var alybgcolor=new Array(parseInt("0x"+bgcolor.substring(0,2)),parseInt("0x"+bgcolor.substring(2,4)),parseInt("0x"+bgcolor.substring(4,6)));var colordelta=new Array((alycolor[0]-alybgcolor[0])/times,(alycolor[1]-alybgcolor[1])/times,(alycolor[2]-alybgcolor[2])/times);for(i=0;i<times;i++){var rgb1=alycolor[0]-colordelta[0]*i;var rgb2=alycolor[1]-colordelta[1]*i;var rgb3=alycolor[2]-colordelta[2]*i;cyclecolor[i]="#"+hexa[Math.floor(rgb1/16)] + hexa[Math.floor(rgb1%16)]+hexa[Math.floor(rgb2/16)] + hexa[Math.floor(rgb2%16)]+hexa[Math.floor(rgb3/16)] + hexa[Math.floor(rgb3%16)];}}else for(i=0;i<times;i++)cyclecolor[i]="#"+colorv;}makecolor();for (i=0;i<times;i++){ var towrit = "<span id=\"span"+i+"\" style=\" FONT-WEIGHT: bold; FONT-SIZE: 9pt; VISIBILITY: visible; COLOR:"+cyclecolor[i]+"; font-family:Arail; POSITION: absolute; TOP: -50px \" >"; document.write(towrit); document.write(message[i]); document.write("</span>");} if (document.layers)document.captureEvents(Event.MOUSEMOVE); document.onmousemove = handlerMM; function AKmakesnake() { //make fly snakeif (Pcolorstyle >2){ //exchange colorfor(i=0;i<times;i++)if(keycolor-i>-1)runcolor[keycolor-i]=(keycstate)?cyclecolor[i]:cyclecolor[times-i-1];for(i=0;i<times;i++)if(keycolor+i<times)runcolor[keycolor+i]=(keycstate)?cyclecolor[i]:cyclecolor[times-i-1];if(keycolor == times){keycolor=0;keycstate=(keycstate)?false:true;}else keycolor++;}if(flag){ for (i=times-1; i>=1; i--) { xpos[i]=xpos[i-1]+Math.abs(xspace);ypos[i]=ypos[i-1]; }if (runflag){xpos[0]=x+xspace+basestep*2;ypos[0]=y+yspace+basestep*2;basestep += randkey;if (Math.abs(basestep)>times/3)randkey=(randkey==1)?-1:1;}else{xpos[0]=x+xspace;ypos[0]=y+yspace;}for (i=0; i<times; i++) {var layerleft=(document.all)?eval("span"+(i)+".style.posLeft=xpos[i]"):("document.span"+i+".left=xpos[i]");var layertop=(document.all)?eval("span"+(i)+".style.posTop=ypos[i]"):("document.span"+i+".top=ypos[i]");if (Pcolorstyle >2)(document.all)?eval("span"+(i)+".style.color=runcolor[i]"):("document.span"+i+".color=runcolor[i]");}}var timer=setTimeout("AKmakesnake()",speed)}function handlerMM(e){x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX;y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY;flag=true;}//--></script>
第二步,在<BODY>标签内加入以下代码:
bgcolor="#000000" topMargin=0 MARGINWIDTH="0" MARGINHEIGHT="0" onLoad="preset(10,10,10,1,1);AKmakesnake()" style="OVERFLOW-X: hidden; OVERFLOW-Y: scroll; WIDTH: 100%;OVERFLOW-X: hidden; OVERFLOW-Y: scroll; WIDTH: 100%"
最新网站更新
网站跟随鼠标的发光文字说明
书籍教程站内推荐信息
书籍教程网站地图