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

各位大侠帮帮忙吧
<!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=utf-8" />
<title>无标题文档</title>

<script language="javascript">
 function atest(thisobj){
  var ok=document.getElementById("a").scrollTop;
  var alldiv=document.getElementsByTagName("yes");
  for(var i=0;i<=alldiv.length;i++){
  if(alldiv[i]!=ok){
alldiv[i].scrollTop=ok;
}
  }
 }
   
</script>

  <style type="text/css">
  .a{ position:absolute; height:150px; overflow:auto; overflow-y:auto; left: 406px; top: 2px;}
  .b{ position:absolute; height:150px; overflow:auto; overflow-y:auto; top: 2px; }
  .c{ position:absolute; height:150px; overflow:auto; overflow-y:auto; left: 199px; top: 2px; }
  </style>
</head>

<body>
<div >
<div class="a" onscroll="atest(this)" id="a" name="a">
  <p>ppppppppppppppppppppppppp</p> 
  <p>ppppppppppppppppppppppppp </p> 
  <p>ppppppppppppppppppppppppp </p> 
  <p>ppppppppppppppppppppppppp </p> 
  <p>ppppppppppppppppppppppppp </p> 
  <p>ppppppppppppppppppppppppp </p> 
  <p>ppppppppppppppppppppppppp </p> 
  <p>ppppppppppppppppppppppppp </p> 
  </div>
   
  <div class="b" id="yes" name="yes">
  <p>aaaaaaaaaaaaaaaaaaaaaaaaa</p> 
  <p>aaaaaaaaaaaaaaaaaaaaaaaaa </p> 
  <p>aaaaaaaaaaaaaaaaaaaaaaaaa </p> 
  <p>aaaaaaaaaaaaaaaaaaaaaaaaa </p> 
  <p>aaaaaaaaaaaaaaaaaaaaaaaaa </p> 
  <p>aaaaaaaaaaaaaaaaaaaaaaaaa </p> 
  <p>aaaaaaaaaaaaaaaaaaaaaaaaa </p> 
  <p>aaaaaaaaaaaaaaaaaaaaaaaaa </p> 
  </div>
   
  <div class="c" id="yes" name="yes">
  <p>cccccccccccccccccccccccccc</p> 
  <p>cccccccccccccccccccccccccc </p> 
  <p>cccccccccccccccccccccccccc </p> 
  <p>cccccccccccccccccccccccccc </p> 
  <p>cccccccccccccccccccccccccc </p> 
  <p>cccccccccccccccccccccccccc </p> 
  <p>cccccccccccccccccccccccccc </p> 
  <p>cccccccccccccccccccccccccc </p> 
  </div>
   
</div>
</body>
</html>


JS这部分代码究竟哪里出错了呀?????


------解决方案--------------------
<!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=utf-8" />
<title>无标题文档</title>

<script