不间断滚动文字/图片

<script>
var showboxwidth=400;
var showboxheight=100;
var imagewidth=80;
var imageheight=80;
//单一图片对象
function contentobject(img,title,link)
{
this.img=img;
this.title=title;
this.link=link;
this.echo=echo;
}
function echo(n)
{
return "<span style=\"position:absolute;top:0px;left:"+n*imagewidth+"\"><table cellspacing=0 cellpading=0 border=0><tr><td><a href=\""+this.link+"\"><img src=\""+this.img+"\" width="+imagewidth+" height="+imageheight+" border=0></a></td></tr><tr><td style='text-align:center;font-size:9pt;background-color:black;color:white'>"+this.title+"</td></tr></table></span>";
}
//
contentarray=new Array();
contentarray[0]=new contentobject("a.gif","第1张","http://campus.nbc.net.cn");
contentarray[1]=new contentobject("b.gif","第2张","http://campus.nbc.net.cn");
contentarray[2]=new contentobject("c.gif","第3张","http://campus.nbc.net.cn");
contentarray[3]=new contentobject("d.gif","第4张","http://campus.nbc.net.cn");
contentarray[4]=new contentobject("e.gif","第5张","http://campus.nbc.net.cn");
contentarray[5]=new contentobject("f.gif","第6张","http://campus.nbc.net.cn");
for(spans="",i=0;i<contentarray.length;i++)
{
spans+=contentarray.echo(i);
}
document.write("<div id=showbox style=\"overflow:hidden;position:relative;top:100px;left:100px;width:"+showboxwidth+"px;height:"+showboxheight+"px;border:1px solid black\">"+spans+"</div>");
function ok()
{
for(i=0;i<showbox.children.length;i++)
{
showbox.children.style.pixelLeft-=1;
}
if (showbox.firstChild.style.pixelLeft<=-showbox.firstChild.offsetWidth)
{
showbox.appendChild(showbox.firstChild.cloneNode(true));
showbox.lastChild.style.pixelLeft=showbox.firstChild.style.pixelLeft+contentarray.length*imagewidth;
showbox.removeChild(showbox.firstChild);
}
//if()
//{
//}
}
timer=setInterval("ok()",1);
</script>
posted @ 2006-08-18 12:41  MSDI  阅读(234)  评论(0编辑  收藏  举报