在html中加上这段代码- <script>
- function startMarquee(h, speed, delay, sid) {
- var t = null;
- var p = false;
- var o = document.getElementById(sid);
- o.innerHTML += o.innerHTML;
- o.onmouseover = function() {p = true}
- o.onmouseout = function() {p = false}
- o.scrollTop = 0;
- function start() {
- t = setInterval(scrolling, speed);
- if(!p) {
- o.scrollTop += 2;
- }
- }
- function scrolling() {
- if(p) return;
- if(o.scrollTop % h != 0) {
- o.scrollTop += 2;
- if(o.scrollTop >= o.scrollHeight/2) o.scrollTop = 0;
- } else {
- clearInterval(t);
- setTimeout(start, delay);
- }
- }
- setTimeout(start, delay);
- }
- startMarquee(30, 60, 0, 'scrollbody');
- </script>
复制代码 |