向上滚动公告(原)

向上滚动公告

<script language="javascript">
var sIndexinfo = [['http://www.baidu.com/','百度网'],['http://www.sina.com.com/','新浪网'],['http://www.sohu.com/','搜狐网']];
function buildAdHtml(info){
var _html = "<div style='overflow:hidden;height:20px;line-height:20px;font-size:12px' id='marqueebox0'>";
    for(var i=0 ;i<info.length;i++){
        _html += "<a href='"+unescape(info[i][0])+"' target='blank'><b>"+unescape(info[i][1])+"</b></a><br>";
    }
    _html += "</div>";
    return _html;
}
document.write(buildAdHtml(sIndexinfo));

function startmarquee(lh,speed,delay,index){
var t;
var p=false;
var o=document.getElementById("marqueebox"+index);
o.innerHTML+=o.innerHTML;
o.onmouseover=function(){p=true}
o.onmouseout=function(){p=false}
o.scrollTop = 0;
function start(){
t=setInterval(scrolling,speed);
if(!p) o.scrollTop += 2;
}
function scrolling(){
if(o.scrollTop%lh!=0){
o.scrollTop += 2;
if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0;
}else{
clearInterval(t);
setTimeout(start,delay);
}
}
setTimeout(start,delay);
}
startmarquee(20,50,5000,0); 
  
</script>

 

你可能感兴趣的:(JavaScript,html,百度,公告)