- JScript code
<script language="javascript" type="text/javascript"><!--var demo = document.getElementById("demo");var demo1 = document.getElementById("demo1");var demo2 = document.getElementById("demo2");var speed=10; //滚动速度值,值越大速度越慢demo2.innerHTML = demo1.innerHTML //克隆demo2为demo1function Marquee(){ if(demo2.offsetTop-demo.scrollTop<=0) //当滚动至demo1与demo2交界时 demo.scrollTop-=demo1.offsetHeight //demo跳到最顶端 else{ demo.scrollTop++ }}var MyMar = setInterval(Marquee,speed); //设置定时器demo.onmouseover = function(){clearInterval(MyMar)} //鼠标经过时清除定时器达到滚动停止的目的demo.onmouseout = function(){MyMar = setInterval(Marquee,speed)} //鼠标移开时重设定时器--></script>
- HTML code
<div align="center" id="demo" style="overflow:hidden;height:200px;width:95px;border-width:1px 1px 1px 1px;border-style:dotted dotted dotted dotted;"> <div id="demo1"> <!-- 定义内容--> 将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放将阿拉法拉发放 </div> <div id="demo2"></div></div>
------解决方案--------------------------------------------------------
代码整理下啊,先加载下
window.onload=function()
{
//代码放这里。
}