<div class="codetitle"> <span><a style="CURSOR: pointer" data="30260" class="copybut" id="copybut30260" onclick="doCopy('code30260')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code30260"> <br> <br> <br> <br><title>分别用marquee和div+js实现首尾相连循环滚动效果</title> <br> <br> <br>用marquee实现首尾相连循环滚动效果(仅IE):<br><br> <br><marquee behavior="scroll" contenteditable="true" onstart="this.firstChild.innerHTML+=this.firstChild.innerHTML;" scrollamount="3" width="100"><span unselectable="on">这里是要滚动的内容</span></marquee> <br><br><br>用DIV+javascript实现首尾相连循环滚动效果(兼容firefox):<br><br> <br><div id="scrollobj" style="white-space:nowrap;overflow:hidden;width:500px;"><span>这里是要滚动的内容</span></div> <br><script language="javascript" type="text/javascript"> <BR><!-- <BR>function scroll(obj) { <BR>var tmp = (obj.scrollLeft)++; <BR>//当滚动条到达右边顶端时 <BR>if (obj.scrollLeft==tmp) obj.innerHTML += obj.innerHTML; <BR>//当滚动条滚动了初始内容的宽度时滚动条回到最左端 <BR>if (obj.scrollLeft>=obj.firstChild.offsetWidth) obj.scrollLeft=0; <BR>} <BR>setInterval("scroll(document.getElementById('scrollobj'))",20); <BR>//--> <BR></script> <br> <br> <br> </div>