适合做公告板的代码收集
投稿:mdxy-dxy
这篇文章主要介绍了适合做公告板的代码收集
1. 每条文字信息循环显示,
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
2.逐行显示文字,转换过程中带有渐隐渐显效果
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
3.每条新闻信息以打字的方式轮流出现
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
4.滚轴式向上滚动文字,每次只显示一行
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
5.文字信息一条接一条显示
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
6.加亮卷动是在视觉上引起兴趣,多次卷动。 它逐渐地将每个信息进从底部升到顶端的视线中,是显示文本的一种好方法。
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
7.可以一条一条的显示文字,也可以点击展开全部文字
<style>
<!--
#listbutton{
border:1px solid #4B4B4B;
background-color:#F3F3F3;
width:50px;
height:12px;
font: normal 11px Arial;
text-align:center;
cursor:pointer;cursor:hand;
}
.expandhighlight, .expandhighlight a{
color:red;
}
-->
</style>
<script language="JavaScript1.2">
//configure tickercontents[] to set the messges you wish be displayed (HTML codes accepted)
var tickercontents=new Array()
tickercontents[0]=’用数据广播方式,将信息内容完整镜像到PC机中’
tickercontents[1]=’数据广播作为广播电视系统的新一代业务。’
tickercontents[2]=’重新构思文化共享结构成为信息产业追求的目标之一。’
//configure the below 2 variables to set the width/background color of the ticker
var tickerwidth=’475’
var tickerbgcolor=’#DDDDFF’
//configure the below variable to determine the delay between ticking of messages (in
miliseconds)
var tickdelay=3000
////Do not edit pass this line////////////////
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
var ns4=document.layers
var currentmessage=0
var tickercontentstotal=’’
function changetickercontent(){
if (ns4){
tickerobj.document.tickernssub.document.write(’<b><a href="#" onClick="return expandlist
(event)">显/隐</a></b> | ’+tickercontents[currentmessage])
tickerobj.document.tickernssub.document.close()
}
else if (ie4||ns6){
tickerobj.innerHTML=tickercontents[currentmessage]
previousmessage=(currentmessage==0)? tickercontents.length-1 : currentmessage-1
tickerexpand_item=ns6? document.getElementById("expand"+currentmessage) : eval
("expand"+currentmessage)
tickerexpand_previousitem=ns6? document.getElementById("expand"+previousmessage) : eval
("expand"+previousmessage)
tickerexpand_previousitem.className=""
tickerexpand_item.className="expandhighlight"
}
currentmessage=(currentmessage==tickercontents.length-1)? 0 : currentmessage+1
setTimeout("changetickercontent()",tickdelay)
}
function start_ticking(){
if (ns4) document.tickernsmain.visibility="show"
tickerobj=ie4? tickerlist : ns6? document.getElementById("tickerlist") : ns4?
document.tickernsmain : ""
tickerexpandobj=ie4? tickerexpand : ns6? document.getElementById("tickerexpand") : ns4?
document.expandlayer : ""
for (i=0;i<tickercontents.length;i++) //get total scroller contents
tickercontentstotal+=’<div id="expand’+i+’">- ’+tickercontents[i]+’</div>’
if (ie4||ns6)
tickerexpandobj.innerHTML=tickercontentstotal
else{
tickerexpandobj.document.write(tickercontentstotal)
tickerexpandobj.document.close()
}
changetickercontent()
}
function expandlist(e){
if (ie4||ns6){
tickerexpand_parent=ie4? tickerexpand.parentElement : document.getElementById
("tickerexpand").parentNode
tickerexpand_parent.style.display=(tickerexpand_parent.style.display=="none")? "" : "none"
}
else{
document.expandlayer.left=e.pageX-e.layerX
document.expandlayer.top= e.pageY-e.layerY+20
document.expandlayer.visibility=(document.expandlayer.visibility=="hide")? "show" : "hide"
return false
}
}
if (ie4||ns6)
document.write(’<table border="0" style="width:’+tickerwidth+’;border:1px solid black;text-
indent:2px" bgcolor="’+tickerbgcolor+’" cellspacing="0" cellpadding="0"><tr><td width="90%"
id="tickerlist" bgcolor="’+tickerbgcolor+’"></td><td width="10%"
bgcolor="’+tickerbgcolor+’"><div id="listbutton" onClick="expandlist()">显/隐
</div></td></tr><tr style="display:none"><td id="tickerexpand" width="90%"
bgcolor="’+tickerbgcolor+’"> </td><td width="10%"></td></tr></table>’)
window.onload=start_ticking
</script>
<ilayer id="tickernsmain" width=&{tickerwidth}; bgColor=&{tickerbgcolor};
visibility=hide><layer id="tickernssub" width=&{tickerwidth}; left=0 top=0></layer></ilayer>
<layer id="expandlayer" bgColor=&{tickerbgcolor}; visibility=hide></layer>
7.在文字转换间加上了类似灯光遮照的效果
以下代码加入<head>区域<SCRIPT>
<!--
function correct(){
if (finished){
setTimeout("begin()",3000)
}
return true
}
window.onerror=correct
function begin(){
if (!document.all)
return
if (maxheight==null)
maxheight=temp.offsetHeight
whatsnew.style.height=maxheight
temp.style.display="none"
c=1
finished=true
change()
}
//-->
</SCRIPT>以下代码加入<body>区域<table height=45 cellspacing=1 cellpadding=1 width="80%"
bgcolor=#000000 border=0 align="center">
<tbody>
<tr>
<td bgcolor=#D7E4F2>
<div align=center>
<script language=javascript1.2>
<!--
var head=’’
var top=0
var maxheight
var finished=false
var tickers=new Array()
tickers[0]=’Microsoft Visual Basic 提供了开发Microsoft Windows应用程序的最迅速,最简捷的方法
。’
tickers[1]=’Xml是当前最流行的开发工具,适合各种平台的开发应用’
tickers[2]=’Asp是最简单的网站开发程序,学习它能帮你更好的了解网络’
tickers[3]=’JavaScript 是网页设计者不可不学的脚本语言’
tickers[4]=’以上这些是一个网站建设者应该具备的条件!’
for (i=1;i<=tickers.length-1;i++){
if (tickers[i].length>=tickers[top].length)
top=i
}
if (document.all)
document.write(’<span id="whatsnew" style="width:100%;height=10;filter:revealTrans
(duration=2,transition=19)">’+tickers[0]+’</span>’)
function change(){
whatsnew.innerHTML=’’
whatsnew.filters.revealTrans.apply()
whatsnew.filters.revealTrans.play()
whatsnew.innerHTML=tickers[c]
if (c==tickers.length-1)
c=0
else
c+=1
setTimeout("change()",5000)
}
if (document.all)
document.write(’<span id=ns style="display:none;">’)
//-->
</script>
<!--Insert alternate HTML codes here
that will be seen by browsers OTHER
than IE 4.x-->
<span
id=temp style="LEFT: 0px; POSITION: absolute; TOP: 0px">
</span> </div>
</td>
</tr>
</tbody>
</table>
8.文字一段一段的显示,每次交换时都带有渐隐渐显的效果
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]