简单的文字轮显效果

2008-09-22 08:48:00 | 【

预设好几条文字信息,程序会轮换显示各条信息,这个脚本的轮换过程不带动画效果

查看全部代码 View Code

在<body>区添加以下代码:

<script language="JavaScript1.2">

        /*****************************************************
         *  Share JavaScript (http://www.ShareJS.com)
         * 使用此脚本程序,请保留此声明
         * 获取此脚本以及更多的JavaScript程序,请访问 http://www.ShareJS.com
         ******************************************************/
    
//configure tickercontents[] to set the messges you wish be displayed (HTML codes accepted)//设置内容显示
var tickercontents=new Array()
tickercontents[0]='See what\'s New at ShareJS.com. <a href="http://www.sharejs.com">[Read more]</a>'
tickercontents[1]='Browse the most popular scripts on Dynamic Drive <a href="http:///dynamicdrive.com/hot.htm">[Read more]</a>'
tickercontents[2]='Link back to Dynamic Drive! <a href="http://dynamicdrive.com/link.htm">[Read more]</a>'

//configure the below 2 variables to set the width/background color of the ticker//设置颜色与长度
var tickerwidth='65%'
var tickerbgcolor='lightblue'

//configure the below variable to determine the delay between ticking of messages (in miliseconds//设置延迟时间
var tickdelay=3000

////Do not edit pass this line////////////////

var currentmessage=0

function changetickercontent(){
if (document.layers){
document.tickernsmain.document.tickernssub.document.write(tickercontents[currentmessage])
document.tickernsmain.document.tickernssub.document.close()
}
else if (document.all)
tickerie.innerHTML=tickercontents[currentmessage]

if (currentmessage==tickercontents.length-1) currentmessage=0
else currentmessage++
setTimeout("changetickercontent()",tickdelay)
}

function start_ticking(){
if (document.layers)
document.tickernsmain.visibility="show"
changetickercontent()
}

if (document.all)
document.write('<div id="tickerie" style="width:'+tickerwidth+'; background-color:'+tickerbgcolor+'"></div>')
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>

下载"简单的文字轮显效果"

  • 本地下载
  • 本地下载2

相关资源