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 以下代码加入区域
CCTV 快报: |
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
4.滚轴式向上滚动文字,每次只显示一行
document.write('
'
+''
+'
|
[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>
<>
</style>
<scriptlanguage="JavaScript1.2">
//configuretickercontents[]tosetthemessgesyouwishbedisplayed(HTMLcodesaccepted)
vartickercontents=newArray()
tickercontents[0]='用数据广播方式,将信息内容完整镜像到PC机中'
tickercontents[1]='数据广播作为广播电视系统的新一代业务。'
tickercontents[2]='重新构思文化共享结构成为信息产业追求的目标之一。'
//configurethebelow2variablestosetthewidth/backgroundcoloroftheticker
vartickerwidth='475'
vartickerbgcolor='#DDDDFF'
//configurethebelowvariabletodeterminethedelaybetweentickingofmessages(in
miliseconds)
vartickdelay=3000
////Donoteditpassthisline////////////////
varie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
varns6=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
varns4=document.layers
varcurrentmessage=0
vartickercontentstotal=''
functionchangetickercontent(){
if(ns4){
tickerobj.document.tickernssub.document.write('<b><ahref="#"onClick="returnexpandlist
(event)">显/隐</a></b>|'+tickercontents[currentmessage])
tickerobj.document.tickernssub.document.close()
}
elseif(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)
}
functionstart_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++)//gettotalscrollercontents
tickercontentstotal+='<divid="expand'+i+'">-'+tickercontents[i]+'</div>'
if(ie4||ns6)
tickerexpandobj.innerHTML=tickercontentstotal
else{
tickerexpandobj.document.write(tickercontentstotal)
tickerexpandobj.document.close()
}
changetickercontent()
}
functionexpandlist(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"
returnfalse
}
}
if(ie4||ns6)
document.write('<tableborder="0"style="width:'+tickerwidth+';border:1pxsolidblack;text-
indent:2px"bgcolor="'+tickerbgcolor+'"cellspacing="0"cellpadding="0"><tr><tdwidth="90%"
id="tickerlist"bgcolor="'+tickerbgcolor+'"></td><tdwidth="10%"
bgcolor="'+tickerbgcolor+'"><divid="listbutton"onClick="expandlist()">显/隐
</div></td></tr><trstyle="display:none"><tdid="tickerexpand"width="90%"
bgcolor="'+tickerbgcolor+'"></td><tdwidth="10%"></td></tr></table>')
window.onload=start_ticking
</script>
<ilayerid="tickernsmain"width=&{tickerwidth};bgColor=&{tickerbgcolor};
visibility=hide><layerid="tickernssub"width=&{tickerwidth};left=0top=0></layer></ilayer>
<layerid="expandlayer"bgColor=&{tickerbgcolor};visibility=hide></layer>
7.在文字转换间加上了类似灯光遮照的效果
以下代码加入<head>区域<SCRIPT>
<>
</SCRIPT>以下代码加入<body>区域<tableheight=45cellspacing=1cellpadding=1width="80%"
bgcolor=#000000border=0align="center">
<tbody>
<tr>
<tdbgcolor=#D7E4F2>
<divalign=center>
<scriptlanguage=javascript1.2>
<>
</script>
<>
<span
id=tempstyle="LEFT:0px;POSITION:absolute;TOP:0px">
</span></div>
</td>
</tr>
</tbody>
</table>
8.文字一段一段的显示,每次交换时都带有渐隐渐显的效果
var scroller_width=150 var scroller_height=120 var bgcolor='#f7f9fd' var pause=3000 //SET PAUSE BETWEEN SLIDE (3000=3 seconds) var scrollercontent=new Array() //Define scroller contents. Extend or contract array as needed scrollercontent[0]='Visit our partner site Freewarejava.com for free Java applets!' scrollercontent[1]='Got JavaScript? JavaScript Kit is the most comprehensive JavaScript site online.' scrollercontent[2]='Link to Dynamic Drive on your site. Please visit our links page.' var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1 var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1 if (ie4||dom) document.write('') else if (document.layers){ document.write(''+scrollercontent[0] +'') } var curpos=scroller_height*(1) var degree=10 var curcanvas="canvas0" var curindex=0 var nextindex=1 function moveslide(){ if (curpos>0){ curpos=Math.max(curpos-degree,0) tempobj.style.top=curpos } else{ clearInterval(dropslide) if (crossobj.filters) crossobj.filters.alpha.opacity=100 else if (crossobj.style.MozOpacity) crossobj.style.MozOpacity=1 nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1" tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas) tempobj.innerHTML=scrollercontent[curindex] nextindex=(nextindex
推荐文章 猜你喜欢 附近的人在看 推荐阅读 拓展阅读 相关阅读 网友关注 最新Javascript教程学习 热门Javascript教程学习 |