function startmarquee(lh, speed, delay) {
        var t;
        var oHeight = 373; /** div的高度 **/
        var p = false;
        var o = document.getElementById("comList");
        var preTop = 0;
        o.scrollTop = 0;
        function start() {
            t = setInterval(scrolling, speed);
            o.scrollTop += 1;
        }
        function scrolling() {
            if (o.scrollTop % lh != 0 && o.scrollTop % (o.scrollHeight - oHeight - 1) != 0) {
                preTop = o.scrollTop;
                o.scrollTop += 1;
                if (preTop >= o.scrollHeight || preTop == o.scrollTop) {
                    o.scrollTop = 0;
                }
            } else {
                clearInterval(t);
                setTimeout(start, delay);
            }
        }
        setTimeout(start, delay);

        o.onmouseover = function () {
            clearInterval(t);
        }
        o.onmouseout = function () {
            start();
        }
    }
    startmarquee(20, 40, 0);//一次滚动的高度,速度,停顿的时间秒

posted on 2014-12-03 15:45  幻想时空  阅读(4532)  评论(0编辑  收藏  举报