自动滚动的div scroll

效果地址请看:http://www.xbwl.cn/bho/website/aboutXB/award!init.action?pageType=00&subType=0&fw=320

 

<div id="aa"          

style="width: 660px; overflow-x: scroll; scroll: auto; scrollbar-face-color: #D8D8D8; /*顶

端面*/ scrollbar-shadow-color: #D8D8D8; /*右下顶边*/ scrollbar-highlight-color: #E3E3E3; /*

左上墙体*/ scrollbar-3dlight-color: #D8D8D8; /*左上顶边*/ scrollbar-darkshadow-color:

#B7B7B7; /*右下墙体*/ scrollbar-track-color: #f1f1f1; /*底色*/ scrollbar-arrow-color:

#FFFFFF;">

</div>

 


<script>
var moveWidth = 0;
var moveSpeed = 10;
var moveLong  = 1;
var moveWay   = 'left';
var stopTime  = 5 * 1000;
var where;
var d = document;
 
function Marquee()
{
    if(d.getElementById("aa").scrollLeft+700 >= d.getElementById("aa").scrollWidth)
 {
  move('right');
  d.getElementById("aa").scrollLeft -= moveLong;
 }
 else if(d.getElementById("aa").scrollLeft==0)
 {
  move('left');
  d.getElementById("aa").scrollLeft += moveLong;
 }
    else
 {
  if(moveWay=='left'){
   d.getElementById("aa").scrollLeft += moveLong
  }else{
   d.getElementById("aa").scrollLeft -= moveLong;
  }
  moveWidth += moveLong;
 }
}
function move(way){
 if(way=='speed'){
  if(moveLong==1){
   moveLong = 3;
   d.getElementById("speed").innerHTML = '减慢';
  }else{
   moveLong = 1;
   d.getElementById("speed").innerHTML = '加速';
  }
 }
 else{
  moveWay = way;
 }
}
 
var Mar=setInterval("Marquee()",moveSpeed);
d.getElementById("aa").onmouseover = function(){
 d.getElementById('aa').style.overflowX = 'scroll';
 where = d.getElementById("aa").scrollLeft;
 clearInterval(Mar);
}
d.getElementById("aa").onmouseout  = function(){
 d.getElementById('aa').style.overflowX = 'hidden';
 if(where < d.getElementById("aa").scrollLeft){
  move('left');
 }
 else if(where > d.getElementById("aa").scrollLeft){
  move('right');
 }
 Mar = setInterval("Marquee()",moveSpeed);
}
</script>

你可能感兴趣的:(scroll)