日期:2014-05-16  浏览次数:20479 次

js简单滚动
<div id="gegz">         <!--gegz开始处-->
     <h3>广而告之<span><a href="/sites/tv/list/qhdst_list.htm?columnid=5803">更多>></a></span></h3>
<div id="demo" style="overflow:hidden;height:100px;">
<div id="demo1">
     <ul style="list-style:none">
       <li><a href="/publish/tv/5803/2010/20101222124533653664144/20101222124533653664144_.html" title="55555">55555</a></li>
       <li><a href="/publish/tv/5803/2010/20101222105117526638419/20101222105117526638419_.html" title="444444444">444444444</a></li>
       <li><a href="/publish/tv/5803/2010/20101222105106842292389/20101222105106842292389_.html" title="333333333">333333333</a></li>
       <li><a href="/publish/tv/5803/2010/20101222105056780535381/20101222105056780535381_.html" title="22222222">22222222</a></li>
       <li><a href="/publish/tv/5803/2010/20101222105045634893481/20101222105045634893481_.html" title="11111111111">11111111111</a></li>
</ul>
</div>
<div id=demo2></div>
</div>
<script language="javascript"> 
var speed=30 
document.getElementById("demo2").innerHTML=document.getElementById("demo1").innerHTML 
function Marquee(){ 
if(demo2.offsetTop-demo.scrollTop<=0) 
demo.scrollTop-=demo1.offsetHeight 
else{ 
demo.scrollTop++ 


var MyMar=setInterval(Marquee,speed) 
demo.onmouseover=function() {clearInterval(MyMar)} 
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)} 
</script>

<p class="lr_bottom"></p>
</div>


########################################
实现思路:两个一样的DIV,通过改变demo的scrolltop来实现连续滚动

offsetHeight:  对象的实际大小,而width表示对象的百分比
scrolltop: 对象对窗口的上端的距离
.....(其他同理)