日期:2014-05-17 浏览次数:20449 次
<div id="demoabc" style="overflow:hidden;width:710px; white-space:nowrap;"> <div id="demoabc1"> <%=gonggaoinfo%> </div> <div id="demoabc2"></div> </div> <script type="text/javascript"> var dirabc = 1//每步移动像素,数大为快 var speedabc = 20//循环周期(毫秒)数大为慢 demoabc2.innerHTML = demoabc1.innerHTML function Marqueeabc() {//正常移动 //offsetWidth元素宽 //scrollLeft页面利用滚动条滚动到右侧时,隐藏在滚动条左侧的页面的宽度 if (dirabc > 0 && (demoabc2.offsetWidth - demoabc.scrollLeft) <= 0) demoabc.scrollLeft = 0 if (dirabc < 0 && (demoabc.scrollLeft <= 0)) demoabc.scrollLeft = demoabc2.offsetWidth demoabc.scrollLeft += dirabc demoabc.onmouseover = function () { clearInterval(MyMarabc) } //暂停移动 demoabc.onmouseout = function () { MyMarabc = setInterval(Marqueeabc, speedabc) } //继续移动 } function r_leftabc() { if (dirabc = -1) dirabc = 1 } //换向左移 function r_rightabc() { if (dirabc = 1) dirabc = -1 } //换向右移 var MyMarabc = setInterval(Marqueeabc, speedabc) </script> </div>