一个可以文本显示的公告栏,可以在多处使用,绝对不可错过!
脚本说明:
第一步:把如下代码加入head区域中
=""
!--
vari=0;
=-1;
=();
varHelpText="";
//usedtoloadmessage
varText="";
//lengthoftimeout(smallerisfaster)
varSpeed=50;
//usedtodisplaymessagenumber
varmessage=0;
//usedtopositiontextinver2.0
varaddPadding="rn";
//EachelementofTextInputrepresentsasinglemessage.
TextInput[0]="今天注意了有新的任务布置";
TextInput[1]="欢迎你的光临!本站为你提供大量javascript下载";
TextInput[2]="重点介绍Javascript";
TextInput[3]="与制作网页特效密切相关的技术";
TextInput[4]="本站同时有影音空间等栏目";
TextInput[5]="还有新闻及健康方面的资料";
TextInput[6]="还有宽带网方面的大量技术文章";
TextInput[7]="本站网址:http://www.njcatv.net";
TotalTextInput=7;//(0,1,2,3,4,5,6,7)
//Positioningandspeedvarybetweenversions.
varVersion=navigator.appVersion;
if(Version.substring(0,1)==3)
{
Speed=200;
addPadding="";
}
for(varaddPause=0;addPause=TotalTextInput;addPause++)
{TextInput[addPause]=addPadding+TextInput[addPause];}
varTimerId
varTimerSet=false;
//Calledbybutton(displaynextmessage).
functionnextMessage()
{
if(!TimerSet)
{
TimerSet=true;
clearTimeout(TimerId);
if(TextNumber=TotalTextInput)
{
alert("Thisistheendofthelist!");
TimerSet=false;
}
else
{
TextNumber+=1;
message=TextNumber+1;
document.forms[0].elements[2].value=message;
Text=TextInput[TextNumber];
HelpText=Text;
}
teletype();
}
}
//GetsanddisplayscharacterfromrollMessage().
//VariableSpeedcontrolslengthoftimeoutandthusthespeedoftyping.
functionteletype()
{
if(TimerSet)
{
Text=rollMessage();
TimerId=setTimeout("teletype()",Speed);
document.forms[0].elements[0].value=Text;
}
}
//Pullsonecharacteratatimefromstringandreturns(asText)tofunctionteletype()fordisplaying.
functionrollMessage()
{
i++;
varCheckSpace=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);
}
//InitiallycalledbyonLoadinBODYtagtoloadtitle.
functioninitTeleType()
{
Text="rnManualTele-TypeDisplay";
document.forms[0].elements[0].value=Text;
}
//Calledbybutton(getpreviousmessage).
functionlastMessage()
{
if(!TimerSet&TextNumber!=-1)
{
TimerSet=true;
clearTimeout(TimerId);
if(TextNumber=0)
{
alert("Thisisthebeginningofthelist!");
TimerSet=false;
}
else
{
TextNumber-=1;
message=TextNumber+1;
document.forms[0].elements[2].value=message;
Text=TextInput[TextNumber];
HelpText=Text;
}
teletype();
}
}
//DeactivateCloaking--/script
第二步:在body区域中加入如下代码:
form
tableCELLSPACING="0"CELLPADDING="0"WIDTH="17%"
tr
tdwidth="100%"colspan="3"valign="top"divalign="center"ptextareaNAME="teletype"ROWS="3"COLS="28"wrap="yes"/textarea/td
/tr
tralign="center"
tdwidth="40%"valign="top"bgcolor="#0000A0"inputTYPE="button"VALUE="公告栏"onClick="lastMessage()"/td
tdwidth="30%"bgcolor="#0000A0"valign="top"inputTYPE="text"value="共8条"SIZE="5"name="1"/td
tdwidth="30%"bgcolor="#0000A0"valign="top"inputTYPE="button"VALUE="阅读"onClick="nextMessage()"/td
/tr
/table
/form
本文链接
http://www.luyixian.cn/javascript_show_123015.aspx