可以文本显示的公告栏的js代码

2016-02-19 10:21 68 1 收藏

岁数大了,QQ也不闪了,微信也不响了,电话也不来了,但是图老师依旧坚持为大家推荐最精彩的内容,下面为大家精心准备的可以文本显示的公告栏的js代码,希望大家看完后能赶快学习起来。

【 tulaoshi.com - Web开发 】

一个可以文本显示的公告栏,可以在多处使用,绝对不可错过! 
脚本说明: 
第一步:把如下代码加入head区域中 
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] = "今天注意了有新的任务布置"; 
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) 
// 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 
第二步:在body区域中加入如下代码: 
form 
table CELLSPACING="0" CELLPADDING="0" WIDTH="17%" 
tr 
td width="100%" colspan="3" valign="top"div style="text-align:center"ptextarea NAME="teletype" ROWS="3" COLS="28" wrap="yes"/textarea /td 
/tr 
tr style="text-align:center" 
td width="40%" valign="top" bgcolor="#0000A0"input TYPE="button" VALUE="公告栏" onClick="lastMessage()"/td 
td width="30%" bgcolor="#0000A0" valign="top"input TYPE="text" value="共8条" SIZE="5" name="1"/td 
td width="30%" bgcolor="#0000A0" valign="top"input TYPE="button" VALUE="阅 读" onClick="nextMessage()"/td 
/tr 
/table 
/form

来源:https://www.tulaoshi.com/n/20160219/1594358.html

延伸阅读
标签: Web开发
代码演示效果为“2007年2月25日星期日正午12:42:48”。 使用方法:将下面的JS代码放到你想要显示的页面中(支持HTML页面),然后在你想要显示时间的位置插入下面的代码即可 div id="Clock" style="text-align:center" style="font-size: 12px; color:#000000"/div JS代码如下: script function ...
标签: Web开发
做项目时自己写一段js给大家。关于文本限制字数的问题,在实际开发中经常用到;主要问题出现在对中文的限制,下面代码就解决关于限制字节数的校验问题;只要将此下代码保存到一个js文件中并引入到校验的页面中,便可使用!同时希望大家给与大力支持和宝贵意见,本人会在今后闲余之际,发表更多的好文章,谢谢!! 以下是引用片段: /*  v...
1、判断网页是否过期 getTime() 用于实现广告过期.  <head <h1判断网页是否过期</h1 <hr <script <!-- today = new Date() //取得现在的时间 TheDay = new Date(2005,12,31) //取得结束的时间 2006/1/4 00:00:00 //如果 today.getTime() &n...
标签: Web开发
上次在blueidea上看到一个元素圆角的实现方法,但是那个太复杂了。于是就自己写了一个函数,可以将元素自动圆角。  演示地址:http://longbill.cn/down/sample/roundcorner.htm  不要用在有 padding 值得元素上,最好是在外面套一层。详情见演示地址。  代码:  function RoundCorner(obj,style)  ...
标签: Web开发
代码如下: html head title类似框架的JS导航菜单/title meta http-equiv=content-Type content="text/html;charset=gb2312" !--把下面代码加到head与/head之间-- SCRIPT language=JavaScript             function secBoard(n)    &n...

经验教程

479

收藏

81
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部