链接的动态变换
我是JS初学者,昨天练习了链接的动态变换,但是对于这段代码有好多地方不理解。希望哪位高手能够教教在下,非常感谢!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<!--样式-->
<style>
<!--
#tickertape{
position:relative;
layer-background-color:black;
width:400;
height:12;
font-family: "宋体"; font-size: 9pt}
#subtickertape{
background-color:black;
position:absolute;
border: 1px solid black;
width:400;
height:12;
font-family: "宋体"; font-size: 9pt}
.subtickertapefont{
font:bold 9pt "宋体";
text-decoration:none;
color:white;
}
.subtickertapefont a{
color:white;
text-decoration:none;
font-family: "宋体"; font-size: 9pt}
-->
</style>
<!--样式-->
<body onload="if (document.all||document.layers) {regenerate2();update()}">
<div id="tickertape" >
<div id="subtickertape" class="subtickertapefont" style="left: 276px; top: 11px; width: 209px; height: 8px">
正在初始化...
</div>
</div>
<script language="JavaScript1.2">
//默认速度4.5秒,自己修改速度快慢。
var speed=4000
var news=new Array()
news[0]="<a href='link1.htm'>随意链接一</a>"
news[1]="<a href='link2.htm'>随意链接二</a>"
news[2]="<a href='link3.htm'>随意链接三</a>"
news[3]="<a href='link4.htm'>随意链接四</a>"
news[4]="<a href='link5.htm'>随意链接五</a>"
news[5]="<a href='link6.htm'>随意链接六</a>"
news[6]="<a href='link7.htm'>随意链接七</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>
</body>