代碼如下:
<BODY>
//借助于marquee
<MARQUEE behavior="scroll" contenteditable="true" onstart="this.firstChild.innerHTML+=this.firstChild.innerHTML;" scrollamount="3" width="100">
<SPAN unselectable="on">這里是要滾動(dòng)的內(nèi)容</SPAN>
</MARQUEE>
//普通的實(shí)現(xiàn)方法
<DIV id="scrollobj" style="white-space:nowrap;overflow:hidden;width:500px;">
<span>這里是要滾動(dòng)的內(nèi)容</span>
</DIV>
<script language="javascript" type="text/javascript">
function scroll(obj) {
var tmp = (obj.scrollLeft)++;
//當(dāng)滾動(dòng)條到達(dá)右邊頂端時(shí)
if (obj.scrollLeft==tmp) obj.innerHTML += obj.innerHTML;
//當(dāng)滾動(dòng)條滾動(dòng)了初始內(nèi)容的寬度時(shí)滾動(dòng)條回到最左端
if (obj.scrollLeft>=obj.firstChild.offsetWidth) obj.scrollLeft=0;
}
setInterval("scroll(document.getElementById('scrollobj'))",20);
</script>
</BODY>
更多信息請(qǐng)查看IT技術(shù)專欄