⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 824text9.htm

📁 javascript各种效果的实例及源代码
💻 HTM
字号:
<html>
<head>
<title>自由控制文字输入</title>
<style type="text/css">
<!--
body {  font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 0px; margin-right: 0px}
A { COLOR: black; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: none }
 A:hover { COLOR: red; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: underline }
a:active     { font: 9pt "宋体"; cursor: hand; color: #FF0033 }

-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#fef4d9" onLoad="titleDisplay()">
<br>
<br>
<center><font color=red face="隶书" size=6>自由控制文字输入</font></center>
<br>
<center>
<table border=5 bordercolor=blue borderlight=green>
<tr><td align=center><font size=5 color=red face="Arial, Helvetica, sans-serif"><strong>下面为效果显示区!</strong></font></td></tr>
<tr><td align=center><SCRIPT>


<!--  Activate Cloaking Device




// used to track position in message


   var i = 0; 


// used to cycle thru messages                                          


   var TextNumber = 0;


// array of messages                        


   var TextInput = new Object();


// used to load manipulate message          


   var HelpText="";                              


// used to load message


   var Text = "";  


// length of timeout (smaller is faster)                                  


   var Speed=150;


// added to end of each message to create a pause


   var WaitSpace="                "


// used to position text in ver 2.0


   var addPadding="\r\n";





// Each element of TextInput represents a single message.


TextInput[0] = "在瞧了金庸先生的封笔之作《鹿鼎记》后,笔者更是颇有些感触.";  


TextInput[1] = "坏男孩该是副什么模样呢?也许就如同《鹿鼎记》中的韦小宝一般吧,一个精灵跳脱的小无赖?.";


TextInput[2] = "他能哄就哄,能骗就骗,侠士嘛说不上,高人嘛更是做不得.";


TextInput[3] = "但是,小无赖也罢,坏男孩也罢,这种男孩具有一种让女孩子们不能不接受的求爱精神,即“三疯精神”,叫“猎狗、疯狗、赖皮狗”,物色对象时象猎狗,求爱时像疯狗,耗上了像赖皮狗。";


TextInput[4] = "虽说这提法有些过分偏激之处,却也正点中了要害。如果真的认真按此精神去对付女孩子,恐怕无一幸免了!";


TextInput[5] = "坏男孩到底用了什么手段那么能招人爱呢?这正如雅俗之分.";


TextInput[6] = "雅,好象是高人一等的,所谓“阳春白雪”者;俗,好象是低人一等的,所谓“下里巴人”者也";


TextInput[7] = "然而高人一等者,“国中属而和者不过数十人”;低人一等者,“国中属而和者数千人”。究竟谁高谁低,不可!";


TotalTextInput = 7; // (0, 1, 2, 3, 4, 5, 6, 7)





// Positioning and speed vary between versions.


var Version =  navigator.appVersion;  


if (Version.substring(0, 1)==3)


   {


   Speed=200;


   addPadding="";


   }





for (var addPause = 0; addPause <= TotalTextInput; addPause++) 


   {TextInput[addPause]=addPadding+TextInput[addPause]+WaitSpace;}





var TimerId


var TimerSet=false;





// Called by the Start button.


function startMessage() 


   {


   if (!TimerSet)


      {


      TimerSet=true;


      teletype();


      }


   }





// Gets and displays character from rollMessage() . 


// Variable Speed controls length of timeout and thus the speed of typing.


function teletype() 


   {


   Text=rollMessage();


   TimerId = setTimeout("teletype()", Speed)


   document.forms[0].elements[0].value=Text;


   }





// Pulls one character at a time from string and returns (as Text) to function teletype() for displaying.


function rollMessage () 


   {


   Wait_yn=false;


   i++;


   var CheckSpace = HelpText.substring(i-1, i);


   CheckSpace = "" + CheckSpace;


   if (CheckSpace == " ") 


      {i++;}


   if (i >= HelpText.length+1) 


      {


      i=0; 


      if (TextNumber < TotalTextInput) 


         {TextNumber++;} 


      else {TextNumber = 0;} 


      initMessage();


      }


   Text = HelpText.substring(0, i);


   return (Text);


   }





// Called from onLoad in BODY tag & resetDisplay().


function titleDisplay()


   {


   document.forms[0].elements[0].value="\r\n                    点开始键文字自动显示";


   initMessage();


   }





// Sets Text & HelpText equal to messages for use in rollMessage ().


function initMessage() 


   {


   Text = TextInput[TextNumber]


   HelpText = Text;


   }





// Called by Stop button.


function stopMessage() 


   {


   TimerSet=false; 


   clearTimeout (TimerId); 


   }





// Called by Reset button.


function resetDisplay()


   {


   TimerSet=false; 


   clearTimeout (TimerId);


   TextNumber=0;


   i=0;


   titleDisplay();   


   }








// Deactivate Cloaking -->

</SCRIPT>

<form>
<TEXTAREA ROWS=2 COLS=55 wrap=yes></TEXTAREA>
<BR>
<TABLE BORDER=0 WIDTH=300>
<TD align="center"><INPUT TYPE="button" VALUE="开始" onClick="startMessage()">
<TD align="center"><INPUT TYPE="button" VALUE="重置" onClick="resetDisplay()">
<TD align="center"><INPUT TYPE="button" VALUE="停止" onClick="stopMessage()">
</TABLE>
</td></tr>
</table></center>
<br>
<br>
<center>
<textarea name=source rows=12 cols=45 class=yk9>
脚本说明:
第一步:把如下代码加入<body>区域中
<SCRIPT>


<!--  Activate Cloaking Device




// used to track position in message


   var i = 0; 


// used to cycle thru messages                                          


   var TextNumber = 0;


// array of messages                        


   var TextInput = new Object();


// used to load manipulate message          


   var HelpText="";                              


// used to load message


   var Text = "";  


// length of timeout (smaller is faster)                                  


   var Speed=50;


// added to end of each message to create a pause


   var WaitSpace="                "


// used to position text in ver 2.0


   var addPadding="\r\n";





// Each element of TextInput represents a single message.


TextInput[0] = "This is just another method of displaying information to your visitors.";  


TextInput[1] = "The routine is based on the T-Banner by Tomer and Yehuda Shiran.";


TextInput[2] = "I've selected the TextArea for display to utilize the wrap-around feature.";


TextInput[3] = "The messages can be made to cycle manually, check out Tele-Type 1 in Tim's Lab.";


TextInput[4] = "Though this scheme is not perfect, you have to admit it is different!";


TextInput[5] = "I've learned that you can reduce flicker by shortening the messages.";


TextInput[6] = "One may want to add speed adjustment to better match individual machines.";


TextInput[7] = "Whether practical or not, at least it was fun developing Timothy's Tele-Type Display!";


TotalTextInput = 7; // (0, 1, 2, 3, 4, 5, 6, 7)





// Positioning and speed vary between versions.


var Version =  navigator.appVersion;  


if (Version.substring(0, 1)==3)


   {


   Speed=200;


   addPadding="";


   }





for (var addPause = 0; addPause <= TotalTextInput; addPause++) 


   {TextInput[addPause]=addPadding+TextInput[addPause]+WaitSpace;}





var TimerId


var TimerSet=false;





// Called by the Start button.


function startMessage() 


   {


   if (!TimerSet)


      {


      TimerSet=true;


      teletype();


      }


   }





// Gets and displays character from rollMessage() . 


// Variable Speed controls length of timeout and thus the speed of typing.


function teletype() 


   {


   Text=rollMessage();


   TimerId = setTimeout("teletype()", Speed)


   document.forms[0].elements[0].value=Text;


   }





// Pulls one character at a time from string and returns (as Text) to function teletype() for displaying.


function rollMessage () 


   {


   Wait_yn=false;


   i++;


   var CheckSpace = HelpText.substring(i-1, i);


   CheckSpace = "" + CheckSpace;


   if (CheckSpace == " ") 


      {i++;}


   if (i >= HelpText.length+1) 


      {


      i=0; 


      if (TextNumber < TotalTextInput) 


         {TextNumber++;} 


      else {TextNumber = 0;} 


      initMessage();


      }


   Text = HelpText.substring(0, i);


   return (Text);


   }





// Called from onLoad in BODY tag & resetDisplay().


function titleDisplay()


   {


   document.forms[0].elements[0].value="\r\n         AutoCycle Tele-Type Display";


   initMessage();


   }





// Sets Text & HelpText equal to messages for use in rollMessage ().


function initMessage() 


   {


   Text = TextInput[TextNumber]


   HelpText = Text;


   }





// Called by Stop button.


function stopMessage() 


   {


   TimerSet=false; 


   clearTimeout (TimerId); 


   }





// Called by Reset button.


function resetDisplay()


   {


   TimerSet=false; 


   clearTimeout (TimerId);


   TextNumber=0;


   i=0;


   titleDisplay();   


   }








// Deactivate Cloaking -->

</SCRIPT>

<form>
&lt;TEXTAREA ROWS=2 COLS=55 wrap=yes&gt;&lt;/TEXTAREA&gt;
<BR>
<TABLE BORDER=0 WIDTH=300>
<TD align="center"><INPUT TYPE="button" VALUE="Start" onClick="startMessage()">
<TD align="center"><INPUT TYPE="button" VALUE="Reset" onClick="resetDisplay()">
<TD align="center"><INPUT TYPE="button" VALUE="Stop" onClick="stopMessage()">
</TABLE>



第二步:把如下代码加入<body>区域中
<body bgcolor="#fef4d9" onLoad="titleDisplay()">
</textarea>
<SCRIPT LANGUAGE="JavaScript">

<!-- hide

function goHist(a) 

{

   history.go(a);

}

//-->

</script>

<FORM METHOD="post">
<INPUT TYPE="button" VALUE="返回" onClick="goHist(-1)" style="background-color: #8000FF; color: rgb(255,255,255)">
</form>
</center>
<br>
<br>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -