181、文字飘动输出

181、文字飘动输出

脚本说明:

把如下代码加入<body>区域中

 

   <SCRIPT LANGUAGE=JAVASCRIPT>

 

 var ltext="超级www.7stk.com欢迎你的光临!!!" /*the message*/

 

 var spc=10 /*spacing*/

 

 var speed=50 /*speed in milliseconds*/

 

 var times=2 /*number of times to run each style*/

 

 

 

 /* DISPLAY DIMENTIONS */

 

 var rows=5 /*number of textarea rows*/

 

 var cols=60 /*number of textarea coloums*/

 

 

 

 /* ADVANCED OPTIONS */

 

 var addstopbutton=true /*add optional stop button? ture=yes false=no*/

 

 var stopbuttonvalue="                 STOP                     " /* Text For Stop Button */

 

 var startvalue="                 START                     " /* When Stop Button Clicked Button Value=? */

 

 

 

 /* END OF OPTIONS */

 

 

 

 var len=spc*2;var text=ltext;var i;

 

 var stop=false;var stopped;

 

 for (i=0;i<spc;i++){text=text+" "}

 

 function array(n) {

 

 this.length = n

 

 for (i=1; i <= n; i++){this[i] ="";}

 

 return this}

 

 

 

 document.writeln('<FORM NAME="F">')

 

 document.writeln('<TEXTAREA ROWS='+rows+' COLS='+cols+' NAME="D" WRAP=SOFT<>/TEXTAREA>')

 

 if (addstopbutton){document.writeln('<BR><INPUT TYPE=BUTTON VALUE="'+stopbuttonvalue+'" ONCLICK="stopstart()" NAME=SS>')}

 

 document.writeln('</FORM>')

 

 

 

 var l=text.length

 

 var ll=ltext.length;

 

 var lb=new array(l)

 

 var lr=new array(spc*2+1)

 

 var lg=new array(ll)

 

 var lk=new array(ll)

 

 lb[0]=text;

 

 lb[l]=text;

 

 for (j=1;j<l;j++){

 

         for (i=1;i<=l;i++){

 

                 lb[j]=lb[j]+lb[j-1].charAt(i);if(i==l){lb[j]=lb[j]+lb[j-1].charAt(0)

 

                 }

 

         }}

 

 

 

 lr[0]=ltext;

 

 lr[spc*2]=ltext;

 

 for (i=1;i<=spc;i++){

 

         lr[i]=" "+lr[i-1]

 

         }

 

 for (i=spc*2-1;i>=spc+1;i--){

 

         lr[i]=" "+lr[i+1]

 

         }

 

 

 

 lg[0]=ltext;

 

 var ll=ltext.length;

 

 for (j=1;j<ll;j++){

 

         for (i=lg[j-1].length-2;i>=0;i--){

 

                 lg[j]=lg[j-1].charAt(i)+lg[j];

 

                 }}

 

 lk[ll]=ltext;

 

 for (j=ll-1;j>=0;j--){

 

         for (i=1;i<=l;i++){

 

                 lk[j]=lk[j]+lk[j+1].charAt(i);

 

                 }}

 

 

 

 var lge="";var lbe="";var rle="";

 

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

 

 lge=lge+lg[i]+unescape('%0D%0A')}

 

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

 

 lbe=lbe+lb[l-i]+unescape('%0D%0A')}

 

 for (i=1;i<=rows;i++){

 

 rle=rle+lr[spc*2-i]+unescape('%0D%0A')}

 

 

 

 var c=1;

 

 var i=ll;

 

 var j=0;

 

 var f=0;

 

 

 

 

 

 function lgf(){

 

 if(stop==false){

 

 if(i>ll){j=0;i=i-2};

 

 if(i==0&&j==0){c++;j=1};

 

 if(j!=0){document.F.D.value=lg[i]+unescape('%0D%0A')+document.F.D.value;i++}

 

 if(j==0){document.F.D.value=lg[i]+unescape('%0D%0A')+document.F.D.value;i--}

 

 if(c<=times){setTimeout("lgf()",speed)}else{document.F.D.value=lge;i=0;j=0;c=0;t()}

 

 }

 

 }

 

 

 

 

 

 function t(){

 

 if(stop==false){

 

 if(i>l){i=1};

 

 document.F.D.value=lb[i]+unescape('%0D%0A')+document.F.D.value;i++;j++

 

 if(j<=l*times){setTimeout("t()",speed)}else{document.F.D.value=lbe;i=0;j=0;rl()}

 

 }

 

 }

 

 

 

 function rl(){

 

 if (stop==false){

 

 if(i>=spc*2){i=0};

 

 document.F.D.value=lr[i]+unescape('%0D%0A')+document.F.D.value;

 

 i++;j++;

 

 if(j<len*times){setTimeout("rl()",speed)}else{document.F.D.value=rle;i=ll-1;j=0;trans()}

 

 }}

 

 

 

 function trans(){

 

 if(stop==false){

 

 document.F.D.value=lk[i]+unescape('%0D%0A')+document.F.D.value;i--;

 

 if(i!=1){setTimeout("trans()",speed)}else{i=ll;lgf()}

 

 }}

 

 

 

 function stopstart(){

 

 stopped=stop;

 

 if(stopped==false){stop=true;document.F.SS.value=startvalue}

 

 if(stopped==true){stop=false;document.F.SS.value=stopbuttonvalue;document.F.D.value="";i=11;j=0;c=0;lgf()}

 

 }

 

 

 

 

 

 if (rows>spc||rows>ll){alert("ERROR!\nrows can NOT be more that spaces or message length!!!!\ndont ask why thats just the way it is.")}

 

 if (spc+ll>cols){alert("ERROR!\ncols(coloums) can NOT be less that the message length + spacing length")}

 

 if (rows<=spc&&rows<=ll&&spc+ll<=cols){lgf()}

 

 

 

 </SCRIPT>

 

Write a comment

Comments: 0