<script>
marqueesHeight=18;
stopscroll=false;
shidian1.scrollTop=0;
with(shidian1){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
preTop=0; currentTop=0; stoptime=0;
function init_srolltext(){
shidian2.innerHTML="";
shidian2.innerHTML+=shidian1.innerHTML;
shidian1.innerHTML=shidian2.innerHTML+shidian2.innerHTML;
setInterval("scrollUp()",20);
}
function scrollUp(){
if(stopscroll==true) return;
currentTop+=1;
if(currentTop==19)
{
stoptime+=1;
currentTop-=1;
if(stoptime==100)
{
currentTop=0;
stoptime=0;
}
}
else {
preTop=shidian1.scrollTop;
shidian1.scrollTop+=1;
if(preTop==shidian1.scrollTop){
shidian1.scrollTop=shidian2.offsetHeight-marqueesHeight;
shidian1.scrollTop+=1;
}
}
}
init_srolltext1();
</script>
这段代码可以实现新闻滚动显示,向上滚动,其中shidian1和shidian2是层的名字,下面介绍我的问题:
如果在同一个页面中放入几个同样的代码,只有最后一个可以运行,前面的都不滚动,我想请教各位是不是这里边的变量冲突?如果要修改的话,需要修改哪些变量?请高手指点。