可以文本顯示的公告欄的js代碼
更新時(shí)間:2007年03月11日 00:00:00 作者:
一個(gè)可以文本顯示的公告欄,可以在多處使用,絕對(duì)不可錯(cuò)過!
腳本說明:
第一步:把如下代碼加入<head>區(qū)域中
<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] = "今天注意了有新的任務(wù)布置";
TextInput[1] = "歡迎你的光臨!本站為你提供大量javascript下載";
TextInput[2] = "重點(diǎn)介紹Javascript";
TextInput[3] = "與制作網(wǎng)頁特效密切相關(guān)的技術(shù)";
TextInput[4] = "本站同時(shí)有影音空間等欄目";
TextInput[5] = "還有新聞及健康方面的資料";
TextInput[6] = "還有寬帶網(wǎng)方面的大量技術(shù)文章";
TextInput[7] = "本站網(wǎng)址: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>區(qū)域中加入如下代碼:
<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="#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>
腳本說明:
第一步:把如下代碼加入<head>區(qū)域中
<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] = "今天注意了有新的任務(wù)布置";
TextInput[1] = "歡迎你的光臨!本站為你提供大量javascript下載";
TextInput[2] = "重點(diǎn)介紹Javascript";
TextInput[3] = "與制作網(wǎng)頁特效密切相關(guān)的技術(shù)";
TextInput[4] = "本站同時(shí)有影音空間等欄目";
TextInput[5] = "還有新聞及健康方面的資料";
TextInput[6] = "還有寬帶網(wǎng)方面的大量技術(shù)文章";
TextInput[7] = "本站網(wǎng)址: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>區(qū)域中加入如下代碼:
<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="#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>
相關(guān)文章
firefox(火狐)和ie瀏覽器禁止右鍵和禁止復(fù)制的代碼
多瀏覽器兼容的禁止右鍵和禁止復(fù)制的代碼。2009-09-09CSS 美化表格邊框?yàn)榘枷萘Ⅲw效果的實(shí)現(xiàn)方法
這個(gè)CSS美化實(shí)例應(yīng)該屬于布局的范疇吧。這里的重點(diǎn)是CSS,因此表格使用了TABle,用CSS控制Table的邊框像Windows系統(tǒng)窗體里的邊線一樣,表格邊框?yàn)榘枷萘Ⅲw效果。2009-10-10JavaScript 表格高亮類的應(yīng)用[高級(jí)]
比較高級(jí)的JavaScript表格高亮類的應(yīng)用,代碼中的Js可以摘出來單獨(dú)作為一個(gè)表格高亮的修飾類,使用很方便,可以控制表格某行、某列甚至是行列同時(shí)高亮顯示,運(yùn)行一下可以看效果。2009-11-11