//上下无缝滚动 var speed = 20; var direction = "top"; var tab = document.getelementbyid("scrollbox"); var tab1 = document.getelementbyid("scrollpic"); var tab2 = document.getelementbyid("scrollpic-copy"); var leftdir = document.getelementbyid("leftdir"); var rightdir = document.getelementbyid("rightdir"); tab2.innerhtml = tab1.innerhtml; function marquee() { switch (direction) { case "top": // if (tab2.offsetheight - tab.scrolltop <= 0) { // tab.scrolltop -= tab1.offsetheight; // } // else { tab.scrolltop++; // } break; case "bottom": // if (tab.scrolltop <= 0) { // tab.scrolltop += tab2.offsetheight; // } // else { tab.scrolltop--; // } break; } } function changedirection(dir) { direction = dir; } var timer = setinterval(marquee, speed); tab.onmouseover = function () { clearinterval(timer); }; tab.onmouseout = function () { timer = setinterval(marquee, speed); }; leftdir.onclick = function () { changedirection("top"); }; rightdir.onclick = function () { changedirection("bottom"); };