<DIV id=demo style="OVERFLOW: hidden; HEIGHT: 120px"> 
<DIV id=demo1>这里是 滚动内容
  </DIV>
                      <DIV id=demo2></DIV>
                    </DIV>
 <SCRIPT>
var t=demo.scrollTop
var stopscroll=false  //添加一个控制变量,是否滚动
demo2.innerHTML=demo1.innerHTML+demo1.innerHTML
demo.onmouseover=new Function("stopscroll=true")//鼠标进设置true 不滚
demo.onmouseout=new Function("stopscroll=false")//鼠标出设置false滚
function qswhMarquee(){
if (stopscroll==true) return; //这里加这句就可以.如果=true 直接返回不滚,上面我注释颠倒了
if(demo2.offsetTop-demo.scrollTop<=0)
demo.scrollTop-=demo1.offsetHeight
else
demo.scrollTop++
}
setInterval(qswhMarquee,100)
</SCRIPT>

解决方案 »

  1.   

    楼上的那位大哥,我按你的代码怎么不滚动了,是不是我该错了,我的目的是在大TABLE里面从右想左滚动,我只是把你的TOP该成了LEFT,HEIGHT该成了WIDTH,我是新手,请你指教一二,下面是我的原代码
    <table width="416" border="0" cellspacing="0" cellpadding="0" height="294" align="center">
            <tr> 
              <td height="6" width="198" valign="top">&nbsp;</td>
              <td width="218" height="6">&nbsp;</td>
            </tr>
            <tr> 
              <td height="22" width="198" background="/images/index2_92.gif" valign="top"><img src="/images/index2_91.gif" width="198" height="25"></td>
              <td width="218" background="/images/index2_92.gif" height="22">&nbsp;</td>
            </tr>
            <tr> 
              <td colspan="2" height="231" valign="top" bgcolor="#FFF7EE"><marquee  onmouseover='this.stop()' onmouseout='this.start()' direction=left scrollamount=1 style="HEIGHT: 120px; WIDTH: 373px; overflow: visible" align="center"> 
                <table width = "141" border = "0" height = "151" cellpadding="0" cellspacing="0">
                  <tr> 
                    <?php       
    $str1 = "select * from scroll order by datetime ASC";
    $query1 = mysql_query($str1);
    while($data1=mysql_fetch_array($query1)){
    $id = $data1[id];
    $pic=adpic.$id."-pic.jpg";
           ?>
                    <td height = "152"> 
                      <?php
      for($j =1; $j <2; $j++){
    ?>
                      <table width="170" border="0" height="151" align="center" cellpadding="0" cellspacing="0">
                        <tr> 
                          <td height="15">&nbsp;</td>
                        </tr>
                        <tr> 
                          <td height="139"> 
                            <div align="right"> 
                              <?php
    if(file_exists($pic)){
               ?>
                              <div align="center"> <a href="/"><img src="/adpic/<?php echo $id.'-pic.jpg'?>" border="0" width="165" height="130"></a> 
                              </div>
                              <?php } ?>
                            </div>
                          </td>
                        </tr>
                        <tr> 
                          <td height="17"> 
                            <div align="center"> 
                              <?php echo $data1[name]; ?>
                            </div>
                          </td>
                        </tr>
                      </table>
                      <? }?>
                    </td>
                    <?php } ?>
                  <tr> 
                </table>
                </marquee> </td>
            </tr>
            <tr> 
              <td height="26" width="198"></td>
              <td width="218" height="26"></td>
            </tr>
          </table>
                
      

  2.   

    www.tclcomm.com看看他的原码吧。一看就明白的
      

  3.   

    <DIV id=demo style="OVERFLOW: hidden; WIDTH: 317px; HEIGHT: 110px;valign:top">
    <TABLE cellSpacing=0 cellPadding=0 border=0>
    <TR>
    <TD id=demo1>
    <TABLE cellSpacing=0 cellPadding=3 border=0>
    <TR>
    <TD><IMG src="1.bmp" border=1></A></TD>
    <TD><IMG src="2.gif" border=1></A></TD>
    <TD><IMG src="3.gif" border=1></A></TD>
    </TR>
    </TABLE>
    </TD>
    <TD id=demo2></TD>
    </TR>
    </TABLE>
    </DIV><SCRIPT>
    var speed=20
    demo2.innerHTML=demo1.innerHTML
    function Marquee(){if(demo2.offsetWidth-demo.scrollLeft<=0)
    demo.scrollLeft-=demo1.offsetWidth
    else{  demo.scrollLeft++  }  }
    var MyMar=setInterval(Marquee,speed)
    demo.onmouseover=function(){clearInterval(MyMar)}
    demo.onmouseout=function(){MyMar=setInterval(Marquee,speed)}
    </SCRIPT>