简单实现无间断循环滚动效果

huang   发表时间:2009-02-10 14:01:52   分类:WEB标准   浏览( )   评论( )   收藏日志
添加到网摘:

 

简单实现无间断文字图片等循环滚动效果

HTML代码:

引用内容
<HTML><HEAD><TITLE>无间断滚动原理</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
</HEAD>
<BODY>
<div id="tbmq">
  <table width="300" border="1" align="left" bgcolor="#00CCFF">
    <tr> 
      <td height="30"> </td>
      <td>溜溜show 1</td>
      <td> </td>
    </tr>
    <tr> 
      <td height="30"> </td>
      <td>溜溜show 2</td>
      <td> </td>
    </tr>
    <tr> 
      <td height="30"> </td>
      <td>溜溜show 3</td>
      <td> </td>
    </tr>
    <tr> 
      <td height="30"> </td>
      <td>溜溜show 4</td>
      <td> </td>
    </tr>
    <tr> 
      <td height="30"> </td>
      <td>溜溜show 5</td>
      <td> </td>
    </tr>
  </table>
</div>
<script>
function MqObj(obj,width,height,speed,direct){
obj.contWidth=obj.offsetWidth;// offsetWidth
obj.stopscroll=false;
obj.nowscroll=0;
with(obj){
scrollLeft=0;//
innerHTML+=innerHTML;
style.width=width;
style.height=height;
style.overflowX="hidden";//
style.overflowY="visible";//
noWrap=true;
onmouseover=function(){stopscroll=true};
onmouseout=function(){stopscroll=false};
}
eval("setInterval('doScroll("+obj.id+")',"+speed+")");
}
function doScroll(obj){
if(obj.stopscroll==true) return;
if(obj.nowscroll<obj.contWidth){ // 
obj.scrollLeft=obj.nowscroll++;//scrollLeft
}else{
obj.scrollLeft=0;//scrollLeft
obj.nowscroll=0;
}
}
window.onload=function(){
MqObj(tbmq,"250","200","10")
MqObj(tbmq2,"270","200","50")
}
</script>
<div id="tbmq2"> 
  <table width="300" border="1" align="left" bgcolor="#00CCFF">
    <tr> 
      <td height="30"> </td>
      <td>Q966.com 1</td>
      <td> </td>
    </tr>
    <tr> 
      <td height="30"> </td>
      <td>Q966.com 2</td>
      <td> </td>
    </tr>
    <tr> 
      <td height="30"> </td>
      <td>Q966.com 3</td>
      <td> </td>
    </tr>
    <tr> 
      <td height="30"> </td>
      <td>Q966.com 4</td>
      <td> </td>
    </tr>
    <tr> 
      <td height="30"> </td>
      <td>Q966.com 5</td>
      <td> </td>
    </tr>
  </table>
</div>
</BODY></HTML>

 

运行查看效果:

HTML代码


[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

 

正在读取日志的评论数据,请稍后……
正在加载日志评论签写框,请稍后……
溜溜show会员登录
正在载入溜溜show会员登录...
溜溜show 日志归档
溜溜show 最新评论
{$SideComment}
溜溜show 最新留言
{$SideGB}
溜溜 阿里妈妈广告