菜鸟请教:如何实现,数据的滚动??
请看一下
www.56110.cn的“最新物流货运信息”(左上放)
请问:那里面数据的定时滚动是怎么实现的??
请指点一下,谢谢!!!
------解决方案--------------------直接看它的源代码不就行了
<marquee onmouseover="this.stop();" onmouseout="this.start();" trueSpeed scrollAmount="1" scrollDelay="25" width="100%">
<a href="http://blog.56110.cn/" target="_blank"><font color="blue">热烈庆祝56110博客系统正式上线!欢迎广大客户加入。</font></a>
</marquee>
把这句话改一下放到你的页面中就行了
------解决方案-------------------- <DIV id=scroll_image onmouseover=bMouseOver=0 style= "OVERFLOW: hidden; WIDTH: 202px; HEIGHT: 40px " onmouseout=bMouseOver=1>
<SCRIPT language=javascript>
var scrollerheight=20;
var html,total_area=0,wait_flag=true;
var bMouseOver = 1;/*初始信息位置*/
var scrollspeed = 1;
var waitingtime = 1000; /*等待时间*/
var s_tmp = 0, s_amount = 20;/*滚动的步长*/
var scroll_content=new Array();
var startPanel=0, n_panel=0, i=0;
function startscroll()
{
i=0;
for (i in scroll_content)
n_panel++;
n_panel = n_panel -1 ;
startPanel = Math.round(Math.random()*n_panel);
if(startPanel == 0)
{
i=0;
for (i in scroll_content)
insert_area(total_area, total_area++);
}
else if(startPanel == n_panel)
{
insert_area(startPanel, total_area);
total_area++;
for (i=0; i <startPanel; i++)
{
insert_area(i, total_area);
total_area++;
}
}
else if((startPanel > 0) || (startPanel < n_panel))
{
insert_area(startPanel, total_area);
total_area++;
for (i=startPanel+1; i <=n_panel; i++)
{
insert_area(i, total_area);
total_area++;
}
for (i=0; i <startPanel; i++)
{
insert_area(i, total_area);
total_area++;
}
}
window.setTimeout( "scrolling() ",waitingtime);
}
function scrolling(){
if (bMouseOver && wait_flag)
{
for (i=0;i <total_area;i++){
tmp = document.getElementById( 'scroll_area '+i).style;
tmp.top = parseInt(tmp.top)-scrollspeed;
if (parseInt(tmp.top) <= -scrollerheight){
tmp.top = scrollerheight*(total_area-1);
}
if (s_tmp++ > (s_amount-1)*scroll_content.length){
wait_flag=false;
window.setTimeout( "wait_flag=true;s_tmp=0; ",waitingtime);
}
}
}
window.setTimeout( "scrolling() ",1);
}
function insert_area(idx, n){
html= ' <div style= "left: 0px; width: 100%; position: absolute; top: '+(scrollerheight*n)+ 'px " id= "scroll_area '+n+ ' "> ';
html+=scroll_content[idx];
html+= ' </div> ';
document.write(html);
}
var newsVar = 0;
scroll_content[0]= ' <a href= "# " target= "_blank "> 文字链接一 </a> ';
scroll_content[1]= ' <a href= "# " target= "_blank "> 文字链接二 </a> ';
scroll_content[2]= ' <a href= "# " target= "_blank "> 文字链接三 </a> ';
scroll_content[3]= ' <a href= "# " target= "_blank "> 文字链接四 </a> ';
scroll_content[4]= ' <a href= "# " target= "_blank "> 文字链接五 </a> ';
scroll_content[5]= ' <a href= "# " target= "_blank "> 文字链接5 </a> ';
scroll_content[6]= ' <a href= "# " target= "_blank "> 文字链接6 </a>