Js Code of the announcement board that can be displayed in text

Source: Internet
Author: User

A bulletin board that can be displayed in text can be used in multiple places and must not be missed!
Script description:
Step 1: Add the following code to the <Script language = "JavaScript">
<! -- Activate Cloaking Device
Var I = 0;
// Used to cycle thru messages
Var TextNumber =-1;
// 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;
// Used to display message number
Var message = 0;
// Used to position text in ver 2.0
Var addPadding = "rn ";
// Each element of TextInput represents a single message.
TextInput [0] = "Pay attention to the new Task Arrangement today ";
TextInput [1] = "Welcome! This site provides you with a large number of javascript downloads ";
TextInput [2] = "Focus on Javascript ";
TextInput [3] = "technologies closely related to making special webpage effects ";
TextInput [4] = "this site also has audio and video spaces and other topics ";
TextInput [5] = "news and Health Information ";
TextInput [6] = "a large number of technical articles on Broadband Networks ";
TextInput [7] = "site URL: http://www.njcatv.net ";
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];}
Var TimerId
Var TimerSet = false;
// Called by >>> button (display next message ).
Function nextMessage ()
{
If (! TimerSet)
{
TimerSet = true;
ClearTimeout (TimerId );
If (TextNumber> = TotalTextInput)
{
Alert ("This is the end of the list! ");
TimerSet = false;
}
Else
{
TextNumber + = 1;
Message = TextNumber + 1;
Document. forms [0]. elements [2]. value = message;
Text = TextInput [TextNumber];
HelpText = Text;
}
Teletype ();
}
}
// Gets and displays character from rollMessage ().
// Variable Speed controls length of timeout and thus the speed of typing.
Function teletype ()
{
If (TimerSet)
{
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 ()
{
I ++;
Var CheckSpace = HelpText. substring (I-1, I );
CheckSpace = "" + CheckSpace;
If (CheckSpace = "")
{I ++ ;}
If (I> = HelpText. length + 1)
{
TimerSet = false;
Text = HelpText. substring (0, I );
I = 0;
Return (Text );
}
Text = HelpText. substring (0, I );
Return (Text );
}
// Initially called by onLoad in BODY tag to load title.
Function initTeleType ()
{
Text = "rn Manual Tele-Type Display ";
Document. forms [0]. elements [0]. value = Text;
}
// Called by <button (get previous message ).
Function lastMessage ()
{
If (! TimerSet & TextNumber! =-1)
{
TimerSet = true;
ClearTimeout (TimerId );
If (TextNumber <= 0)
{
Alert ("This is the beginning of the list! ");
TimerSet = false;
}
Else
{
TextNumber-= 1;
Message = TextNumber + 1;
Document. forms [0]. elements [2]. value = message;
Text = TextInput [TextNumber];
HelpText = Text;
}
Teletype ();
}
}
// Deactivate Cloaking --> </script>
Step 2: Add the following code to the <body> area:
<Form>
<Table CELLSPACING = "0" CELLPADDING = "0" WIDTH = "17%">
<Tr>
<Td width = "100%" colspan = "3" valign = "top"> <div align = "center"> <p> <textarea NAME = "teletype" ROWS = "3 "COLS =" 28 "wrap =" yes "> </textarea> </td>
</Tr>
<Tr align = "center">
<Td width = "40%" valign = "top" bgcolor = "#1_a0"> <input TYPE = "button" VALUE = "" onClick = "lastMessage () "> </td>
<Td width = "30%" bgcolor = "# invalid A0" valign = "top"> <input TYPE = "text" value = "8 in total" SIZE = "5" name = ""1"> </td>
<Td width = "30%" bgcolor = "# adjust A0" valign = "top"> <input TYPE = "button" VALUE = "read" onClick = "nextMessage () "> </td>
</Tr>
</Table>
</Form>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.