js无缝滚动,现要求:滚动条数少于3条,则停止滚动。超过三条,便自动滚动。请大神帮忙解决一下
<divclass="bjgs_module"id="bjgs_slide"><divclass="wrap"><ul><li>滚动信息1</li><li>滚动信息2</...
<div class="bjgs_module" id="bjgs_slide">
<div class="wrap">
<ul>
<li>滚动信息1</li>
<li>滚动信息2</li>
<li>滚动信息3</li>
<li>滚动信息4</li>
</ul>
</div>
</div>
//办件公示向上滚动文字
window.onload = function(){
var odiv = document.getElementById("bjgs_slide");
var oul = odiv.getElementsByTagName("ul")[0];
var oli = odiv.getElementsByTagName("li");
var ispeen = -2 ;
var timer = null ;
oul.innerHTML += oul.innerHTML ;
timer=setInterval(doMove,140) ;
function doMove(){
oul.style.top = oul.offsetTop+ispeen+"px";
if(oul.offsetTop < -oul.offsetHeight/2){
oul.style.top = "0px" ;
}else if(oul.offsetTop >0){
oul.style.top = -oul.offsetHeight/2+"px";
};
}
oul.onmouseover = function(){
clearTimeout(timer);
};
oul.onmouseout = function(){
timer=setInterval(doMove,140) ;
};
}; 展开
<div class="wrap">
<ul>
<li>滚动信息1</li>
<li>滚动信息2</li>
<li>滚动信息3</li>
<li>滚动信息4</li>
</ul>
</div>
</div>
//办件公示向上滚动文字
window.onload = function(){
var odiv = document.getElementById("bjgs_slide");
var oul = odiv.getElementsByTagName("ul")[0];
var oli = odiv.getElementsByTagName("li");
var ispeen = -2 ;
var timer = null ;
oul.innerHTML += oul.innerHTML ;
timer=setInterval(doMove,140) ;
function doMove(){
oul.style.top = oul.offsetTop+ispeen+"px";
if(oul.offsetTop < -oul.offsetHeight/2){
oul.style.top = "0px" ;
}else if(oul.offsetTop >0){
oul.style.top = -oul.offsetHeight/2+"px";
};
}
oul.onmouseover = function(){
clearTimeout(timer);
};
oul.onmouseout = function(){
timer=setInterval(doMove,140) ;
};
}; 展开
展开全部
<div id="scroll_div" class="ks_pic">
<div style="height:6000000px;">
<div id="scroll_begin" style="float:left;" >
<div class="ks_pic_img"><img src='/uploads/1.jpg' border='0' width='126'height='160' ></div>
<div class="ks_pic_img"><img src='/uploads/1.jpg' border='0' width='126'height='160' ></div>
<div class="ks_pic_img"><img src='/uploads/1.jpg' border='0' width='126'height='160' ></div>
<div class="ks_pic_img"><img src='/uploads/1.jpg' border='0' width='126'height='160' ></div>
</div>
<div id="scroll_end" style="float:left;" ></div></div>
</div>
<script>
function ScrollImgLeft(){
var speed=20,
doc=document,
scroll_begin = doc.getElementById("scroll_begin"),
scroll_end = doc.getElementById("scroll_end"),
scroll_div = doc.getElementById("scroll_div");
scroll_end.innerHTML=scroll_begin.innerHTML;
function Marquee(){
if(scroll_end.offsetHeight-scroll_div.scrollTop<=0)
scroll_div.scrollTop-=scroll_begin.offsetHeight
else
scroll_div.scrollTop++
}
var MyMar=setInterval(Marquee,speed)
scroll_div.onmouseover=function() {clearInterval(MyMar)}
scroll_div.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}
ScrollImgLeft();
</script>
<div style="height:6000000px;">
<div id="scroll_begin" style="float:left;" >
<div class="ks_pic_img"><img src='/uploads/1.jpg' border='0' width='126'height='160' ></div>
<div class="ks_pic_img"><img src='/uploads/1.jpg' border='0' width='126'height='160' ></div>
<div class="ks_pic_img"><img src='/uploads/1.jpg' border='0' width='126'height='160' ></div>
<div class="ks_pic_img"><img src='/uploads/1.jpg' border='0' width='126'height='160' ></div>
</div>
<div id="scroll_end" style="float:left;" ></div></div>
</div>
<script>
function ScrollImgLeft(){
var speed=20,
doc=document,
scroll_begin = doc.getElementById("scroll_begin"),
scroll_end = doc.getElementById("scroll_end"),
scroll_div = doc.getElementById("scroll_div");
scroll_end.innerHTML=scroll_begin.innerHTML;
function Marquee(){
if(scroll_end.offsetHeight-scroll_div.scrollTop<=0)
scroll_div.scrollTop-=scroll_begin.offsetHeight
else
scroll_div.scrollTop++
}
var MyMar=setInterval(Marquee,speed)
scroll_div.onmouseover=function() {clearInterval(MyMar)}
scroll_div.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}
ScrollImgLeft();
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询