精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>网络专区>>● 网站建设>>盖世神功 — 网站建设技术>>HTML — 做好一个网页不能没有的基础>>DHTML特效>>特效28:滚动显示的告示牌

主题:特效28:滚动显示的告示牌
发信人: marsz()
整理人: microant(1999-08-02 12:13:18), 站内信件
实例:滚动显示的告示牌
适用浏览器:ALL
 
说明:称这个效果为告示牌是为了形象的说明他的作用, 它将滚动显示信息, 并
适用不同的连结, 用它做个首页链接或宣传使用不是很好吗, 你可以根据自己的
喜好再将它的外观改的漂亮一些.
 
第一步:将下列代码复制到网页的Head和Body标记中间。



<style>
<!--#tickertape{position:relative;layer-background-color:black;width:4
00;height:12;}#subtickertape{background-color:black;position:absolute;
border: 1px solid black;width:400;height:12;}.subtickertapefont{font:b
old 12px Verdana;text-decoration:none;color:white;}.subtickertapefont
a{color:white;text-decoration:none;}-->
</style>

第二步:将下列代码放置你的网页中。



<div id="tickertape">
<div id="subtickertape" class="subtickertapefont">Initializing...</div
>
</div>

<script language="JavaScript1.2">

/*
modified by mars 1999 ,www.joysoft.net
*/
//默认时间是4.5秒, 请更换成你希望的时间
var speed=4500

var news=new Array()
news[0]="进入飞翔鸟软体驿站了解最新的
软件动态
"
news[1]="飞翔鸟硬件资讯站给你最新的硬
件行情!
"
news[2]="想学习vb? Come To CVBU Now!!</
a>"
//于这里增加更多的信息

i=0
if (document.all)
tickerobject=document.all.subtickertape.style
else
tickerobject=document.tickertape.document
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers)
setTimeout("window.onresize=regenerate",450)
}

function update(){
 BgFade(0xff,0xff,0xff, 0x00,0x00,0x00,10);
if (document.layers){
document.tickertape.document.subtickertape.document.write('<span class
="subtickertapefont">'+news[i]+'</span>')
document.tickertape.document.subtickertape.document.close()
}
else 
document.all.subtickertape.innerHTML=news[i]

if (i<news.length-1)
i++
else
i=0
setTimeout("update()",speed)
}

function BgFade(red1, grn1, blu1, red2,
grn2, blu2, steps) {
sred = red1; sgrn = grn1; sblu = blu1;
ered = red2; egrn = grn2; eblu = blu2;
inc = steps;
step = 0;
RunFader();
}
function RunFader() {
var epct = step/inc;
var spct = 1 - epct;
if (document.layers)
tickerobject.bgColor =
Math.floor(sred * spct + ered *
epct)*256*256 +
Math.floor(sgrn * spct + egrn * epct)*256 +
Math.floor(sblu * spct + eblu * epct);
else
tickerobject.backgroundColor=
Math.floor(sred * spct + ered *
epct)*256*256 +
Math.floor(sgrn * spct + egrn * epct)*256 +
Math.floor(sblu * spct + eblu * epct);
if ( step < inc ) {
setTimeout('RunFader()',50);
}
step++;
}

</script>

如果要改变文字,可以直接修改第二步中<span>标记里的内容。

第三步:将 onload="if (document.all||document.layers) {regenerate2();u
pdate()}" 添加到<body>标记中。(如<body onload="if (document.all||docu
ment.layers) {regenerate2();update()}">)

--
天上星 亮晶晶 永灿烂 保安宁

※ 来源:.
月光软件站 http://www.moon-soft.com.[FROM: 202.99.13.146]

[关闭][返回]