[HTML] syntaxhighlighter_viewsource syntaxhighlighter_copycode
<DIV id="scrollobj" style="white-space:nowrap;overflow:hidden;width:300px;" onmouseover="aa()" onmouseout="b()" >
<!--这个里面装内容-->
[aaa]
[bbb]
[ccc]
[ddd]
[eee]
</DIV>
<script language="javascript" type="text/javascript">
function scroll(obj) {
var tmp = (obj.scrollLeft)++; //这里是每次定时器中断来了后都让 scrollLeft自增
if (obj.scrollLeft == tmp) //这个代码在开始的时候才运行一次。。之后都不会运行了
obj.innerHTML += obj.innerHTML;
//当滚动条滚动了初始内容的宽度时滚动条回到最左端
if (obj.scrollLeft>=obj.offsetWidth) //昨天那个obj.firstchild是错的 应该直接取width
obj.scrollLeft = 0;
//firstChild.
}
var a = setInterval("scroll(document.getElementById('scrollobj'))",20);
function aa(){
clearInterval(a);
}
function b(){
a=setInterval("scroll(document.getElementById('scrollobj'))",10);
}
</script>