|
一、在<head>与<head>之间插入以下代码:
<SCRIPT language=javascript>
function gdnewsl(news_id,news_name,news_link,news_content)//存放信息的数组结构
{
this.news_id=news_id;
this.news_name=news_name;
this.news_link=news_link;
this.news_content=news_content;
}
newsl=new Array();//申明信息数组
newsl[1]=new gdnewsl('1','欢迎光临!','http://dnjy.2000y.net','欢迎光临');
newsl[2]=new gdnewsl('2','欢迎光临!','http://dnjy.2000y.net','欢迎光临');
newsl[3]=new gdnewsl('3','欢迎光临!','http://dnjy.2000y.net','欢迎光临');
newsl[4]=new gdnewsl('4','欢迎光临!','http://dnjy.2000y.net','欢迎光临');
newsl[5]=new gdnewsl('5','欢迎光临!','http://dnjy.2000y.net','欢迎光临');
newsl[6]=new gdnewsl('2','欢迎光临!','http://dnjy.2000y.net','欢迎光临');
newsl[7]=new gdnewsl('7','欢迎光临!','http://dnjy.2000y.net','欢迎光临');
newsl[8]=new gdnewsl('8','欢迎光临!','http://dnjy.2000y.net','欢迎光临');
isns = navigator.appName == "Netscape";
function initl()
{
if(isns)
{
tag0='document.divnewsl.document.clipnewsl.document.'
tag1='document.divnewsl.document.clipnewsl.'
tag2=''
}
else
{
tag0=''
tag1=''
tag2='.style'
}
newsnuml=newsl.length-1
if(isns) eval(tag1+'clip.width=280')
eval(tag0+'newsl1'+tag2+'.top=10')
if(isns) eval(tag1+'visibility="show"')
if(newsnuml>7) newsmovel()
}
stephl=1 //移动步长控制变量
nnl=false
strtnum=false
heightlimit=280 //字幕窗口宽度
jg=1 //间隔控制变量
function newsmovel()
{
nnl=true
strtnum=true
yminl=1
for(i=1;i<=newsnuml;i++)
{
if(isns) ytop=eval(tag0+'newsl'+yminl+'.top')
else ytop=eval('newsl'+yminl+'.style.pixelTop')
if(isns) nitop=eval(tag0+'newsl'+i+'.top')
else nitop=eval('newsl'+i+'.style.pixelTop')
if(nitop<ytop) yminl=i
}
if(isns) tt=eval(tag0+'newsl'+yminl+'.top');
else tt=eval('newsl'+yminl+'.style.pixelTop');//这里的T必须大写
tt-=stephl;
eval(tag0+'newsl'+yminl+tag2+'.top=tt');
ymaxl=yminl-1;
if(yminl==1) ymaxl=newsnuml
if(yminl>=1&&yminl<newsnuml)
for(i=yminl+1;i<=newsnuml;i++)
{
j=i-1;
followl(i,j)
}
if(yminl!=1)
for(i=1;i<=ymaxl;i++)
{
j=i-1
if(j==0) j=newsnuml
followl(i,j)
}
for(i=1;i<=newsnuml;i++)
{
if(isns) topi=eval(tag0+'newsl'+i+'.top')
else topi=eval('newsl'+i+'.style.pixelTop')
if(isns) heighti=eval(tag0+'newsl'+i+'.clip.Height')
else heighti=eval('newsl'+i+'.offsetHeight')
buttoni=topi+heighti
if(buttoni<-14)
eval(tag0+'newsl'+i+tag2+'.top=heightlimit')
}
if(nnl) domovel=setTimeout('newsmovel()',20);
}
function stopml()
{
if(nnl)
{clearTimeout(domovel)
nnl=false}
}
function startml()
{
if(!nnl&&strtnum) newsmovel()
}
function followl(nexti,prei)
{
if(isns) newtop=eval(tag0+'newsl'+prei+'.top')
else newtop=eval('newsl'+prei+'.style.pixelTop')//这里的T必须大写
if(isns) newheight=eval(tag0+'newsl'+prei+'.clip.Height')
else newheight=eval('newsl'+prei+'.offsetHeight')//这里的H必须大写
newpos=newtop+newheight+jg
if(newpos>heightlimit) newpos=heightlimit
eval(tag0+'newsl'+nexti+tag2+'.top='+newpos)
}
</SCRIPT>
二、在你要插入滚动条的地方插入以下代码:
<div id=clipnewsl style="LEFT: 0px; WIDTH: 150px; CLIP: rect(0px 180px 200px 0px); POSITION: absolute; top: 120px; height: 150">
<script language=javascript>
aal=''
for(i=1;i<newsl.length;i++)
{
dd=(i-1)*50
if(i>1) dd=150
aal="<div id=newsl"+i+" style='position:absolute;top:"+dd+"'>"
if(newsl[i].news_link!='')
aal+="<table border=0 cellpadding=0 cellspacing=0 onmouseover=stopml() onmouseout=startml()><tr><td class=a3 bgcolor='#cccccc' ><a href="+newsl[i].news_link+" target=_blank >"+newsl[i].news_name+"</a>"+newsl[i].news_content+"</td></tr></table></div>"
else
aal+="<table border=0 cellpadding=0 cellspacing=0><tr><td>没有文字链接</td></tr></table></div>"
document.write(aal)
}
</script>
</div>
三、在<body>加上代码onload=initl(),即这样:<body onload=initl()><br>
再按上面的说明修改成你要在滚动字幕中显示的内容 |
|