私人领地

js无间隙滚动

代码一:

var speed=50; //设置文字滚动速度
dome2.innerHTML=dome1.innerHTML //复制dome1为dome2
function Marquee(){
if(dome2.offsetTop-dome.scrollTop<=0) //当滚动至dome1与dome2交界时
dome.scrollTop-=dome1.offsetHeight //dome跳到最顶端
else{
dome.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed) //设置定时器
dome.onmouseover=function() {clearInterval(MyMar)}//鼠标移上时清除定时器达到滚动停止的目的
dome.onmouseout=function() {MyMar=setInterval(Marquee,speed)}//鼠标移开时重设定时器,继续滚动

 

代码二:

var speed = 50;
var demo = document.getElementById("demo");
var demo2 = document.getElementById("demo2");
var demo1 = document.getElementById("demo1");
demo2.innerHTML = demo1.innerHTML;

function Marquee(){
    if(demo2.offsetTop-demo.scrollTop<=0) //当滚动至dome1与dome2交界时
        demo2.scrollTop-=demo1.offsetHeight //dome跳到最顶端
    else{
        demo.scrollTop++
    }
}
var MyMar=setInterval(Marquee,speed) //设置定时器
demo.onmouseover=function() {clearInterval(MyMar);;}//鼠标移上时清除定时器达到滚动停止的目的
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}//鼠标移开时重设定时器,继续滚动

 

代码三:

 

posted @ 2013-08-19 17:45  狂奔的蜗牛Snails  阅读(268)  评论(0编辑  收藏  举报