189、选择显示文字方式

189、选择显示文字方式

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE = "JavaScript">

 

<!-- HTML comment to placate non JavaScript capable browsers

 

function AraVob() {

}

var ScreenLine = new AraVob();

ScreenLine[1]  = "You can display multiple lines of text here,";

ScreenLine[2]  = "including \"blank\" lines.";

ScreenLine[3]  = " ";

ScreenLine[4]  = "Isn't this easier to read than \"sideways\" scrollers?";

ScreenLine[5]  = " ";

ScreenLine[6] = "Click on the \"Type/Scroll\" button to switch between....";

ScreenLine[7] = "  scrolling the page up with complete lines or,";

ScreenLine[8] = "  typing a line and scrolling the page up.";

ScreenLine[9] = " ";

ScreenLine[10] = "Aren't you glad your browser has JavaScript (JScript) power?";

ScreenLine[11] = "Enjoy!....";

/*

To change or add lines, just replace values of or add to ScreenLine[n]

above.   Use \" in the message text for quotes and \t for tabs.

*/

var msgNum = 1;          // set to first message to display

var msgCnt = 11;         // set to number of last ScreenLine to display.

var typeSpeed = 50;      // the typing rate in milliseconds (higher number type more slowly)

var lineDelay = 2000     // the delay time at end of line. (unless the line is a single space)

var pagLen = 6;          // number of lines per page (usually the number of rows in the TEXTAREA)  

var delay = typeSpeed;    

var timerPS = null;

var linPntr = 0;

var tally = 1;

var msg = " ";

var outMsg = "";

var i = 0;

var typingon = false;

 

// set up ScreenLines for display

for (x = msgCnt; 1 <= x; x--) {

  ScreenLine[x+pagLen] = ScreenLine[x] + "\r\n";

}

for (x = 1; x <= (pagLen); x++) {

  ScreenLine[x] =  " \r\n";

}

 msgCnt +=  pagLen;

 msg = ScreenLine[1];

// end setup

 

function SwitchIt() {

 typingon = !typingon;

}

 

function DisplayScroll() {

 if (msgNum < pagLen) {

  delay = typeSpeed;

 }

 else {

  delay = lineDelay;

 }

 ChangeMsg();

 outMsg += msg;

 self.document.msgform.msgarea.value = outMsg;

 if (typingon == true) {

  timerPS = setTimeout("DisplayMsg()",delay);

 }

 else {

  clearTimeout(timerPS);

  timerPS = setTimeout("DisplayScroll()",delay);

 }

}

function DisplayMsg() {

 if (msg.length <= i) {

  i = 0;

  ChangeMsg();

 }

 outMsg += msg.charAt(i);

 i++;

 if (msg.charAt(i) != "\n" || msg == " \r\n") {

  delay = typeSpeed;

 }

 else {

  delay = lineDelay;

 }

 self.document.msgform.msgarea.value = outMsg;

 if (typingon == false) {

  timerPS = setTimeout("DisplayScroll()",delay);

 }

 else {

  clearTimeout(timerPS);

   timerPS = setTimeout("DisplayMsg()",delay);

 }

}

 

function ChangeMsg() {

 msgNum++;

 if (msgCnt < msgNum) {

   msgNum = 1;

 }

 if (pagLen <= tally) {

   chgPage();

 }

 tally++;

 msg = ScreenLine[msgNum];

}

 

function chgPage() {

 if (msgNum < pagLen) {

   linPntr = msgCnt - pagLen + msgNum + 1;

 }

 else {

   linPntr = msgNum - (pagLen - 1);

 }

 

 outMsg =   ScreenLine[linPntr];

 for (p = 1; p < (pagLen - 1); p++) {

   linPntr++;

   if (msgCnt < linPntr) {

     linPntr = 1;

   }

   outMsg += ScreenLine[linPntr];

 }

 

}

 

function quitDisplay() {

  self.document.msgform.msgarea.value = "Type a Page for yourself today!";

}

// -->

 

</SCRIPT>

 

 

<FORM NAME = "msgform" ACTION = " ">

 <TEXTAREA NAME = "msgarea" COLS = 66 ROWS = 6>

 JavaScript (or JScript) Power needed.

 </TEXTAREA>

</FORM>

<FORM>

  <INPUT TYPE="button"

         NAME="button1"

         VALUE="逐个显示/逐行显示"

         onClick="SwitchIt()">

 </FORM>

 

 

 

 

 

第二步:把如下代码加入<body>区域中

<body bgcolor="#fef4d9" onLoad="DisplayMsg()">

 

 

Write a comment

Comments: 0