<br><div class="msgheader"> <div class="right"><span style="CURSOR: pointer" onclick="copycode(getid('phpcode29'));"><u>复制代码</u></span></div>代码如下:</div> <div class="msgborder" id="phpcode29"> <br><br>//借助于marquee<br><marquee behavior="scroll" contenteditable="true" onstart="this.firstChild.innerHTML+=this.firstChild.innerHTML;" scrollamount="3" width="100"><br><span unselectable="on">这里是要滚动的内容</span><br></marquee><br><br>//普通的实现方法<br><div id="scrollobj" style="white-space:nowrap;overflow:hidden;width:500px;"> <br><span>这里是要滚动的内容</span><br> </div> <br><script language="javascript" type="text/javascript"><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 /></script><br> <br> </div>