Go to my github

javascript:滚动新闻

<h5><div id="scrollNews" class="scrollNews" style="overflow: hidden; WIDTH: 700px">
 <nobr>
 <span id="scrollNews_cur">
  <a href="http://news.lfang.com/NewsDetail-47528-1.html">·新地阿尔法国际社区精装豪宅实景呈现</a>
  <a href="http://news.lfang.com/NewsDetail-47528-1.html">·地中海阳光2#楼全新房源即将火爆开盘</a>
  <a href="http://news.lfang.com/NewsDetail-47528-1.html">·正荣大湖之都5月29日湖景多层盛大开盘</a>
  <a href="http://news.lfang.com/NewsDetail-47528-1.html">·金桥慧景儒苑全新房源闪耀面世</a>
  <a href="http://news.lfang.com/NewsDetail-47528-1.html">·红谷一品低密度电梯多层洋房均价4500元全城发售</a>
 </span><span id="scrollNews_ext"></span>
 </nobr>
 <script defer>
ScrollStup(scrollNewsMar,'scrollNews','scrollNews_cur','scrollNews_ext',20);
</script>
 </div></h5>
 <script language="JavaScript">
function MarqueeSelf(parentDiv,scrollObj,scrollExtObj){
 // alert(2);
       if(document.getElementById(scrollExtObj).offsetWidth-document.getElementById(parentDiv).scrollLeft<=0) //当滚动至rolllink1与rolllink2交界时
        document.getElementById(parentDiv).scrollLeft-=document.getElementById(scrollObj).offsetWidth;  //rolllink跳到最顶端
       else{
        document.getElementById(parentDiv).scrollLeft++;
       }
    }
   var scrollNewsMar;
   function ScrollStup(intVar,parentDiv,scrollObj,scrollExtObj,rollspeed){
       document.getElementById(scrollExtObj).innerHTML=document.getElementById(scrollObj).innerHTML //克隆rolllink1为rolllink2
       intVar=setInterval("MarqueeSelf('"+parentDiv+"','"+scrollObj+"','"+scrollExtObj+"')",rollspeed) //设置定时器
       document.getElementById(parentDiv).onmouseover=function() {clearInterval(intVar)}//鼠标移上时清除定时器达到滚动停止的目的
       document.getElementById(parentDiv).onmouseout=function() {intVar=setInterval("MarqueeSelf('"+parentDiv+"','"+scrollObj+"','"+scrollExtObj+"')",rollspeed)}//鼠标移开时重设定时器
   }
</script>

其他参考:

http://blog.haha168.com/blogview.asp?logID=234

posted @ 2010-06-05 18:14 罗敏贵 阅读(...) 评论(...) 编辑 收藏