你好,想请教“用JS和<marquee>实现的滚动效果为什么滚动一次就停止了?”怎么解决的,谢谢!
我也和你遇到同样问题,想请教一下是怎样解决的。我的JAVA部分代码:<script>varspeed=20demo2.innerHTML=demo1.innerHTMLf...
我也和你遇到同样问题,想请教一下是怎样解决的。
我的JAVA部分代码:
<script>
var speed=20
demo2.innerHTML=demo1.innerHTML
function Marquee()
{
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
HTML代码:
<div id=demo style=overflow:hidden;height:90;width:560;color:#ffffff>
<table align=left cellpadding=0 cellspace=0 border=0>
<tr>
<td id=demo1 valign=top>
<div align="center">
<center><%Call ProductRX()%></center>
</div>
</td>
<td id=demo2 valign=top></td>
</tr>
</table>
</div> 展开
我的JAVA部分代码:
<script>
var speed=20
demo2.innerHTML=demo1.innerHTML
function Marquee()
{
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
HTML代码:
<div id=demo style=overflow:hidden;height:90;width:560;color:#ffffff>
<table align=left cellpadding=0 cellspace=0 border=0>
<tr>
<td id=demo1 valign=top>
<div align="center">
<center><%Call ProductRX()%></center>
</div>
</td>
<td id=demo2 valign=top></td>
</tr>
</table>
</div> 展开
1个回答
展开全部
<script language="javascript" type="text/javascript">
var s,sn=0,timer,slen,timer2;
function scrollInit(){
s=getid("s1");
s.scrollTop=0;
slen=s.innerHTML.split("|");
s.innerHTML="";
for(var i=0;i<slen.length;i++){s.innerHTML+=(slen[i]+"<br />");}
s.innerHTML+=slen[0];
timer2=setInterval(scrollstart,500);
s.onmouseover=function(){clearInterval(timer2);clearInterval(timer);s.style.backgroundColor="#ccc";}
s.onmouseout=function(){timer2=setInterval(scrollstart,3000);s.style.backgroundColor="#fff";}
}
function scrollstart(){
if(s.scrollTop>=(slen.length*20)){s.scrollTop=0;}
timer=setInterval(scrollexec,30);
}
function scrollexec(){
if(sn<20){
sn++;
s.scrollTop++;
}else{
sn=0;
clearInterval(timer);
}
}
window.onload=scrollInit;
var s,sn=0,timer,slen,timer2;
function scrollInit(){
s=getid("s1");
s.scrollTop=0;
slen=s.innerHTML.split("|");
s.innerHTML="";
for(var i=0;i<slen.length;i++){s.innerHTML+=(slen[i]+"<br />");}
s.innerHTML+=slen[0];
timer2=setInterval(scrollstart,500);
s.onmouseover=function(){clearInterval(timer2);clearInterval(timer);s.style.backgroundColor="#ccc";}
s.onmouseout=function(){timer2=setInterval(scrollstart,3000);s.style.backgroundColor="#fff";}
}
function scrollstart(){
if(s.scrollTop>=(slen.length*20)){s.scrollTop=0;}
timer=setInterval(scrollexec,30);
}
function scrollexec(){
if(sn<20){
sn++;
s.scrollTop++;
}else{
sn=0;
clearInterval(timer);
}
}
window.onload=scrollInit;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询