正常的。see demo:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/tr/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
</head>
<body>
<div id="demo" style="width:100px; height:100px; background-color:#333; overflow:auto; color:#eee;">
function foo(o) { alert(o.value); }function foo(o) { alert(o.value); }function foo(o) { alert(o.value); }function foo(o) { alert(o.value); }
</div>
<input type="button" onclick="foo()" value="get"/>
<script type="text/javascript">
function foo() { 
var a =document.getElementById("demo");
alert(a.scrollTop);
}
</script>
  </body>
</html>

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    这个是vs2005创建符合xhtml1.0标准时自己加上去的代码,在这下面scrollTop属性总是为0我就是想在不修改这个的情况下,怎么样才能获取到div的scrollTop的值?
      

  2.   

    这不是一样的吗?
    我用的是xhtml strict你自己试,看看是不是有scrollTop
    <!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>
      <title></title>
    </head>
    <body>
    <div id="demo" style="width:100px; height:100px; background-color:#333; overflow:auto; color:#eee;">
    function foo(o) { alert(o.value); }function foo(o) { alert(o.value); }function foo(o) { alert(o.value); }function foo(o) { alert(o.value); }
    </div>
    <input type="button" onclick="foo()" value="get"/>
    <script type="text/javascript">
    function foo() { 
    var a =document.getElementById("demo");
    alert(a.scrollTop);
    }
    </script>
      </body>
    </html>