电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

滚动文字新闻的制作


发布日期:2018/10/18
 
一句一句话地显示出来有点类似于跑马灯效果文字效果的突出点比较明显推荐使用

制作方法

将下面的代码复制到<body>~</body>里

<script language=JavaScript>

//设置下面的参数(宽度高度和背景色)可以得到不同的显示效果

var scrollerwidth=

var scrollerheight=

var scrollerbgcolor=

//下面的参数不想使用背景图的话设为空

var scrollerbackground=

//下面的参数设置显示内容可以使用HTML语法改变字体大小和颜色及连接等

var messages=new Array()

messages[]=::::::::::::::::::::: 示例滚动新闻 :::::::::::::::::::::

messages[]=<a javascript:void()>新奥特真三维虚拟演播室系统顺利通过广电总局检测</a>

messages[]=<a javascript:void()>新奥特参加年江苏广播电视暨网络设备展览会成功 </a>

messages[]=<a javascript:void()>九运组委会致函感谢新奥特提供电视字幕为九运作出重要贡献</a>

///////下面的代码不要改变//////

if (messageslength>)

i=

else

i=

function move(whichlayer){

tlayer=eval(whichlayer)

if (tlayertop>&&tlayertop<=){

tlayertop=

setTimeout(move(tlayer))

setTimeout(move(documentmaindocumentsecond))

return

}

if (tlayertop>=tlayerdocumentheight*){

tlayertop=

setTimeout(move(tlayer))

}

else{

tlayertop=scrollerheight

tlayerdocumentwrite(messages[i])

tlayerdocumentclose()

if (i==messageslength)

i=

else

i++

}

}

function move(whichlayer){

tlayer=eval(whichlayer)

if (tlayertop>&&tlayertop<=){

tlayertop=

setTimeout(move(tlayer))

setTimeout(move(documentmaindocumentfirst))

return

}

if (tlayertop>=tlayerdocumentheight*){

tlayertop=

setTimeout(move(tlayer))

}

else{

tlayertop=scrollerheight

tlayerdocumentwrite(messages[i])

tlayerdocumentclose()

if (i==messageslength)

i=

else

i++

}

}

function move(whichdiv){

tdiv=eval(whichdiv)

if (tdivstylepixelTop>&&tdivstylepixelTop<=){

tdivstylepixelTop=

setTimeout(move(tdiv))

setTimeout(move(second))

return

}

if (tdivstylepixelTop>=tdivoffsetHeight*){

tdivstylepixelTop=

setTimeout(move(tdiv))

}

else{

tdivstylepixelTop=scrollerheight

tdivinnerHTML=messages[i]

if (i==messageslength)

i=

else

i++

}

}

function move(whichdiv){

tdiv=eval(whichdiv)

if (tdivstylepixelTop>&&tdivstylepixelTop<=){

tdivstylepixelTop=

setTimeout(move(tdiv))

setTimeout(move(first))

return

}

if (tdivstylepixelTop>=tdivoffsetHeight*){

tdivstylepixelTop=

setTimeout(move(second))

}

else{

tdivstylepixelTop=scrollerheight

tdivinnerHTML=messages[i]

if (i==messageslength)

i=

else

i++

}

}

function startscroll(){

if (documentall){

move(first)

secondstyletop=scrollerheight

secondstylevisibility=visible

}

else if (documentlayers){

documentmainvisibility=show

move(documentmaindocumentfirst)

documentmaindocumentsecondtop=scrollerheight+

documentmaindocumentsecondvisibility=show

}

}

windowonload=startscroll

</script>

<ilayer id=main width=&{ scrollerwidth}; height=&{ scrollerheight}; bgcolor=&{ scrollerbgcolor}; visibility=hide top=>

<layer id=first width= top= left=>

<script language=JavaScript>

if (documentlayers)

documentwrite(messages[])

</script>

</layer>

<layer id=second width= visibility=hide top= left=>

<script language=JavaScript>

if (documentlayers)

documentwrite(messages[])

</script>

</layer>

</ilayer>

<script language=JavaScript>

if (documentall){

documentwriteln(<span id=main >)

documentwriteln(<div >)

documentwriteln(<div id=first >)

documentwrite(messages[])

documentwriteln(</div>)

documentwriteln(<div id=second >)

documentwrite(messages[])

documentwriteln(</div>)

documentwriteln(</div>)

documentwriteln(</span>)

}

</script>

注意在message[xxx]中不能含有空格如下

messages[]=<table border=><tr valign=top><td width=>「 // 」</td><td width=></td><td>服务器现在真的是怪怪的刚刚还用了新的地址了一会儿又变<br>成了现在的这个了真是让我干着急真对不起大家啊!</td></tr></table>

正 确

messages[]=<table border=><tr valign=top><td width=>「 // 」</td>

<td width=></td><td>服务器现在真的是怪怪的刚刚还用了新的地址了一会儿又变

<br>成了现在的这个了真是让我干着急真对不起大家啊!</td></tr></table>

错 误

至此你就可以完成这个实例了

上一篇:浅谈在网页上显示日期的两种方法

下一篇:图片在显示一定的时间后消失