<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
Marquee = function(div_main, div_descp, div_show, speed, direction){ 
this.ctl_main = document.getElementById(div_main); 
this.ctl_descp = document.getElementById(div_descp); 
this.ctl_show = document.getElementById(div_show); 
//direction: 1、由下至上 2、由右至左 this.ctl_show.innerHTML = this.ctl_descp.innerHTML; 
this.Run = function() { 
var main = document.getElementById(div_main); 
var descp = document.getElementById(div_descp); 
var show = document.getElementById(div_show); 
switch(direction){ 
case 1: 
if(show.offsetTop-main.scrollTop <=0){ 
main.scrollTop-=descp.offsetHeight; 
}else{ 
main.scrollTop++; 

break; 
case 2: 
if(show.offsetWidth-main.scrollLeft <=0){ 
main.scrollLeft-=descp.offsetWidth 
}else{ 
main.scrollLeft++ 

break; 
} } 
var func = this.Run; 
var obj = setInterval(func, speed); 
this.ctl_main.onmouseover = function(){ 
clearInterval(obj); 
} this.ctl_main.onmouseout = function(){ 
obj = setInterval(func, speed) 

} </script>
 <script type="text/javascript"> 
        function PageLoad(){ 
            var marObj=new Marquee("div_marquee_main","div_marquee_descp","div_marquee_show",20,1); 
        } 
    </script> </head><body onload="PageLoad()"> 
    <div id="div_marquee_main" style="background-color: White; overflow: hidden; width: 100px; 
        color: #ffffff; height: 100px;"> 
                    <div id="div_marquee_descp"> 
                        <table width="100" height="100" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" height="80"><img src="images/index_3.gif" width="100" height="73" /></td>
    <td align="center" height="80"><img src="images/index_3.gif" width="100" height="73" /></td>
    <td align="center" height="80"><img src="images/index_3.gif" width="100" height="73" /></td>
  </tr>
  <tr>
    <td height="20" align="center">你好</td>
    <td align="center">你好</td>
    <td align="center">你好</td>
  </tr>
</table>
                    <div id="div_marquee_show"> 
                    </div> 
    </div> 
</body> </html>

解决方案 »

  1.   

    chinmo大哥近来一切安好!
    给楼主一些建议:
    this.ctl_main = document.getElementById(div_main);
    this.ctl_descp = document.getElementById(div_descp);
    this.ctl_show = document.getElementById(div_show); 

    var main = document.getElementById(div_main); 
    var descp = document.getElementById(div_descp); 
    var show = document.getElementById(div_show); switch语句最好补上default:;
      

  2.   

    一切都好,他的JS没有问题
    是他的HTML有问题
      

  3.   

    呵呵呵
    继续建议:
    测试js动态操作DOM的时候最好给指定的元素加上背景色,以便于区分;js+css一个也少不了