document.body.scrollTop和document.documentElement.scrollTop返回值都是0
在顶部这样配的
<!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">
不管用哪个都是0,但是
e=e||event;
e.clientX;
能取到值跪求高手指点

解决方案 »

  1.   

    试试这个
    var scrollY=0;
    if(document.documentElement&&document.documentElement.scrollTop){
    scrollY=document.documentElement.scrollTop;}
    else if(document.body&&document.body.scrollTop){
    scrollY=document.body.scrollTop;}
    else if(window.pageYOffset){
    scrollY=window.pageYOffset;}
    else if(window.scrollY){
    scrollY=window.scrollY;}
      

  2.   

    前辈,那个也是0function show_tip_test(e){
    var obj=document.getElementById("flowDiv");
    obj.style.display="block";
    e=e||event;
    obj.style.left=e.clientX+"px";
    obj.style.top=document.documentElement.scrollTop+e.clientY+"px";
    setTimeout("document.getElementById('flowDiv').style.display='none'",3000);
    alert(document.documentElement.scrollTop);
    alert(document.body.scrollTop);
    }<a href="#" onclick="show_tip_test(event)">会员中心</a><div id="flowDiv" style="width:130px; height:20px; background:url(../images/tishi_02.gif) repeat-x ; position:absolute; display:none; z-index:10;">
    <span style="float:left;font-size:medium;color:#fff;">网站封测中</span>
    <span style="float:right;color:#fff;" onclick="close_tip_test();">[X]</span>
    </div>
      

  3.   

    net_lover前辈,我知道错了……我用您那个:function show_tip_test(e){
    var scrollY=0;
    if(document.documentElement&&document.documentElement.scrollTop){
    scrollY=document.documentElement.scrollTop;}
    else if(document.body&&document.body.scrollTop){
    scrollY=document.body.scrollTop;}
    else if(window.pageYOffset){
    scrollY=window.pageYOffset;}
    else if(window.scrollY){
    scrollY=window.scrollY;} var obj=document.getElementById("flowDiv");
    obj.style.display="block";
    e=e||event;
    obj.style.left=e.clientX+"px";
    obj.style.top=scrollY+e.clientY+"px";        setTimeout("document.getElementById('flowDiv').style.display='none'",3000);
    }
    在鼠标点击的地方出来了,但是整个页面返回顶部了,对不起,我太菜了这个怎么做让浏览器定到用户看到的地方?
      

  4.   

    <a href="#" onclick="show_tip_test(event);return false;">会员中心</a>
      

  5.   

    原来要加一个return false。
      

  6.   

    用window.scrollY和window.pageYOffset返回的都是undefined