适合做公告板的代码收集
1. 每条文字信息循环显示,
以下代码加入区域
#oneLiners {
background-color:#00c;
color:#fd0;
font-weight:bold;
}
在中加上onLoad="setOneLiners();"
以下代码加入区域
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
2.逐行显示文字,转换过程中带有渐隐渐显效果
以下代码加入区域
#tic {
/* enter any styles for the ticker below */
border: .05em #CEC3AD solid;
font-size:0.85em;
padding:10px;
width:400px;
line-height:20px;
}
#tic * {
/* this will hide all children tags */
font-size: 1em;
margin:0px;
padding:0px;
display:none;
}
#tic a {
/* add more tags to this list if you wish to display them inside the children */
display:inline;
}
//more javascript from http://www.smallrain.net
var list; // global list variable cache
var tickerObj; // global tickerObj cache
var hex = 255;
function fadeText(divId) {
if(tickerObj)
{
if(hex>0) {
hex-=5; // increase color darkness
tickerObj.style.color="rgb("+hex+","+hex+","+hex+")";
setTimeout("fadeText('" + divId + "')", fadeSpeed);
} else
hex=255; //reset hex value
}
}
function initialiseList(divId) {
tickerObj = document.getElementById(divId);
if(!tickerObj)
reportError("Could not find a div element with id \"" + divId + "\"");
list = tickerObj.childNodes;
if(list.length 0)
list[count-1].style.display = "none";
else
list[list.length-1].style.display = "none";
count++;
if(count == list.length)
count = 0;
window.setTimeout("run('" + divId + "', " + count+ ")", interval*1000);
}
function reportError(error) {
alert("The script could not run because you have errors:\n\n" + error);
return false;
}
var interval = 7; // interval in seconds
var fadeSpeed = 40; // fade speed, the lower the speed the faster the fade. 40 is normal.
以下代码加入区域
什么是ASP?
Active Server Pages(ASP,活动服务器页面)就是一个编程环境,在其中,可以
混合使用HTML、脚本语言以及组件来创建服务器端功能强大的Internet应用程序。
如果你以前创建过一个站点,其中混合了HTML、脚本语言以及组件,你就可以在其中加入ASP程序代码。
通过在HTML页面中加入脚本命令,你可以创建一个HTML用户界面,并且,还可以通过使用组件包含一些商
业逻辑规则。
组件可以被脚本程序调用,也可以由其他的组件调用。
什么是 ASP.NET?
ASP.NET 是建立在公共语言运行库上的编程框架,可用于在服务器上生成功能强大的 Web 应用程序。
与以前的 Web 开发模型相比,ASP.NET 提供了数个重要的优点:增强的性能、世界级的工具支持、威力
和灵活性、简易性、可管理性、可缩放性和可用性、自定义性和扩展性、安全性。
什么是PHP?
PHP 是一种用来制作动态网页的服务器端脚本语言。你通过PHP和HTML创建页面。当访问者打开网页时,
服务器端便会处理 PHP 指令,然后把其处理结果送到访问者的浏览器上面,就好像 ASP 或者是
ColdFusion 一样。然而,PHP 跟 ASP 或 ColdFusion 不一样的地方在于,它是跨平台的开放源代码。
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
3.每条新闻信息以打字的方式轮流出现
以下代码加入区域
//more javascript from http://www.smallrain.net
=totalNum||CurrentPosion>=5) CurrentPosion=0; //最多条数不超过5条
}
if(theCurrentLength != theNewsText.length)
{
drawNews();
}
else
{
closeOutNews();
}
}
// --- 跳转下一条新闻
function setupNextNews()
{
theNewsState = 0;
theCurrentNews = theCurrentNews % theNewsNum;
theNewsText = document.getElementById("AllNews").children
[theCurrentNews].children.Summary.innerText;
theTargetLink = document.getElementById("AllNews").children
[theCurrentNews].children.NewsLink.innerText;
theCurrentLength = 0;
document.all.hottext.href = theTargetLink;
theCurrentNews++;
}
function setupAddNews()
{
theNewsState = 0;
theCurrentNews = theCurrentNews % theAddNum;
theNewsText = document.getElementById("incoming").children.AddNews.children
[theCurrentNews].children.Summary.innerText;
theTargetLink = document.getElementById("incoming").children.AddNews.children
[theCurrentNews].children.NewsLink.innerText;
theCurrentLength = 0;
document.all.hottext.href = theTargetLink;
theCurrentNews++;
}
// --- 滚动新闻
function drawNews()
{
var myWidget;
if((theCurrentLength % 2) == 1)
{
myWidget = theWidgetOne;
}
else
{
myWidget = theWidgetTwo;
}
document.all.hottext.innerHTML = theLeadString + theNewsText.substring
(0,theCurrentLength) + myWidget + theSpaceFiller;
theCurrentLength++;
setTimeout("runTheTicker()", theCharacterTimeout);
}
// --- 结束新闻循环
function closeOutNews()
{
document.all.hottext.innerHTML = theLeadString + theNewsText + theSpaceFiller;
theNewsState = 1;
setTimeout("runTheTicker()", theNewsTimeout);
}
window.onload=startTicker;
//-->
以下代码加入区域
CCTV 快报: |
全国政协代表团出访三国 出席经社理事会会议
#
[东方时空]六天七夜降服森林大火
#
香港特区政府就曾荫权请辞政务司司长发表声明
#
刘云山会见老挝客人
#
曾庆红强调先进性教育活动要自始至终注重实效
#
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
4.滚轴式向上滚动文字,每次只显示一行
var strArray=new Array();
strArray[1]='张怡宁王楠晋级八强 牛剑锋不敌朝鲜人遭淘汰'
strArray[0]='美国网球遭遇黑色星期四 罗迪克告别雅典'
strArray[2]='18日:中国军团陷入沉闷 美国日本势头不减'
strArray[3]='中国小球军团不顺 乒、羽分遭冷门和滑铁卢'
strArray[4]='18日中国陷入波谷 射箭女将何影展示风范>'
showId=Math.floor(Math.random()*5);
tempStr=strArray[showId];
strArray[showId]=strArray[0];
strArray[0]=tempStr;
document.write('
' +' ' +'
' ' |
');
marqueesHeight=21;
stopscroll=false;
toptable.scrollTop=0;
with(toptable){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
preTop=0; currentTop=21; stoptime=0;
toptable.innerHTML+=toptable.innerHTML;
function init_srolltext(){
toptable.scrollTop=0;
setInterval("scrollUp()",40);
}init_srolltext();
function scrollUp(){
if(stopscroll==true) return;
currentTop+=1;
if(currentTop==22)
{
stoptime+=1;
currentTop-=1;
if(stoptime==80)
{
currentTop=0;
stoptime=0;
}
}
else {
preTop=toptable.scrollTop;
toptable.scrollTop+=1;
if(preTop==toptable.scrollTop){
toptable.scrollTop=42;
toptable.scrollTop+=1;
}
}
}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
5.文字信息一条接一条显示
以下代码加入区域
#memoryticker{
background-color: lightyellow;
width: 450px;
font: bold 12px Verdana;
/*Tip: add in height attribute here for multiple line scroller*/
border: 1px solid black;
padding: 3px;
/*Change 0.7 below to a different number if desired (0.7=0.7 seconds)*/
/*Remove below line to remove transitional effect in IE. Below line should always appear
last within this CSS*/
filter: progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)
}
以下代码加入区域
//more javascript from http://www.smallrain.net
//configure tickercontents[] to set the messges you wish be displayed (HTML codes accepted)
//Backslash any apostrophes within your text (ie: I\'m the king of the world!)
var tickercontents=new Array()
tickercontents[0]='1) 送你一串风铃'
tickercontents[1]='2) 风起,铃声响,是我对你的思念。'
tickercontents[2]='3) 送你一串风铃,'
tickercontents[3]='4) 思念,带着痛,无奈轻风不解情。 '
var persistlastviewedmsg=1 //should messages' order persist after users navigate away
(1=yes, 0=no)?
var persistmsgbehavior="onload" //set to "onload" or "onclick".
//configure the below variable to determine the delay between ticking of messages (in
miliseconds):
var tickdelay=3000
////Do not edit pass this line////////////////
var divonclick=(persistlastviewedmsg && persistmsgbehavior=="onclick")?
'onClick="savelastmsg()" ' : ''
var currentmessage=0
function changetickercontent(){
if (crosstick.filters && crosstick.filters.length>0)
crosstick.filters[0].Apply()
crosstick.innerHTML=tickercontents[currentmessage]
if (crosstick.filters && crosstick.filters.length>0)
crosstick.filters[0].Play()
currentmessage=(currentmessage==tickercontents.length-1)? currentmessage=0 :
currentmessage+1
var filterduration=(crosstick.filters&&crosstick.filters.length>0)? crosstick.filters
[0].duration*1000 : 0
setTimeout("changetickercontent()",tickdelay+filterduration)
}
function beginticker(){
if (persistlastviewedmsg && get_cookie("lastmsgnum")!="")
revivelastmsg()
crosstick=document.getElementById? document.getElementById("memoryticker") :
document.all.memoryticker
changetickercontent()
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function savelastmsg(){
document.cookie="lastmsgnum="+currentmessage
}
function revivelastmsg(){
currentmessage=parseInt(get_cookie("lastmsgnum"))
currentmessage=(currentmessage==0)? tickercontents.length-1 : currentmessage-1
}
if (persistlastviewedmsg && persistmsgbehavior=="onload")
window.onunload=savelastmsg
if (document.all||document.getElementById)
document.write('
')
if (window.addEventListener)
window.addEventListener("load", beginticker, false)
else if (window.attachEvent)
window.attachEvent("onload", beginticker)
else if (document.all || document.getElementById)
window.onload=beginticker
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
6.加亮卷动是在视觉上引起兴趣,多次卷动。 它逐渐地将每个信息进从底部升到顶端的视线中,是显示文本的一种好方法。
// Highlighter Scroller II script- By (http://www.smallrain.net)
//CONFIGURE MESSAGES AND VARIABLES
var tickercontents=new Array()
tickercontents[0]='08:54法国外交部职员发起全球联合罢工 抗议削减预算
08:26巴以和平日内
瓦倡议正式发起 中国特使出席仪式'
tickercontents[1]='08:22土耳其车队在土东南部遭恐怖袭击造成5死4伤
08:13联合国高度赞扬
中国总理温家宝探访艾滋病人'
tickercontents[2]='08:05央行制定人民币挑剔标准 于2004年1月1日起执行
07:04巴格达袭击似
有核心领导 美将发动钢铁正义行动'
var tickerwidth="200px"
var tickerheight="70px"
var fontcss="font: bold 14px Verdana; color:black"
var tickdelay=3000 //delay btw messages
var highlightspeed=2 //2 pixels at a time.
var highlightcolor="lightyellow"
var backdroptextcolor="#E1E1E1"
////Do not edit pass this line////////////////
document.write('#highlighterbg a{color:'+backdroptextcolor+'}')
document.write('
')
document.write('')
document.write('
')
var currentmessage=0
var clipbottom=1
function changetickercontent(){
msgheight=clipbottom=crosstick.offsetHeight
crosstick.style.clip="rect("+msgheight+"px auto auto 0px)"
crosstickbg.innerHTML=tickercontents[currentmessage]
crosstick.innerHTML=tickercontents[currentmessage]
highlightmsg()
}
function highlightmsg(){
//var msgheight=crosstick.offsetHeight
if (clipbottom>0){
clipbottom-=highlightspeed
crosstick.style.clip="rect("+clipbottom+"px auto auto 0px)"
beginclip=setTimeout("highlightmsg()",20)
}
else{
clipbottom=msgheight
clearTimeout(beginclip)
if (currentmessage==tickercontents.length-1) currentmessage=0
else currentmessage++
setTimeout("changetickercontent()",tickdelay)
}
}
function start_ticking(){
crosstickbg=document.getElementById? document.getElementById("highlighterbg") :
document.all.highlighterbg
crosstick=document.getElementById? document.getElementById("highlighter") :
document.all.highlighter
crosstickParent=crosstick.parentNode? crosstick.parentNode : crosstick.parentElement
if (parseInt(crosstick.offsetHeight)>0)
crosstickParent.style.height=crosstick.offsetHeight+'px'
else
setTimeout("crosstickParent.style.height=crosstick.offsetHeight+'px'",100) //delay for
Mozilla's sake
changetickercontent()
}
if (document.all || document.getElementById)
window.onload=start_ticking
[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= bgColor=
visibility=hide><layer id="tickernssub" width= left=0 top=0></layer></ilayer>
<layer id="expandlayer" bgColor= 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.文字一段一段的显示,每次交换时都带有渐隐渐显的效果
var scroller_width=150 var scrollercontent=new Array() var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1 if (ie4||dom) ') var curpos=scroller_height*(1) function moveslide(){ |
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]