function showImg(evn, flag, space, msg ) {
  var e = (evn == null) ? event : evn;
  var d = document.getElementById('title_div');
  if (flag == 1) {
  d.innerHTML = msg;
  d.style.left = e.clientX + 10 +'px';
  d.style.top = e.clientY + 10 +'px';
  d.style.display = '';
  
  } else {   
   d.style.display = 'none';
  }
  
  }
<div id="title_div" class="div" style="position : absolute ;-moz-opacity:0.8;border: 1px;border-color: red; z-index : 3000000;background-color: black; filter: Alpha(Opacity=50);display : none"> 
</div>

解决方案 »

  1.   

    你要显示的div的位置是根据e.clientY 算来的,而e.clientY并不随滚动条的出现而改变,是脱离文档流从左上顶点计算的相对高度值.
    所以计算方法是错的.运行如下代码就知道了.
    <html>
    <head>
    <meta http-equiv=Content-Type content="text/html; charset=gb2312" />
    <title>
    </title>
    </head>
    <script>
    function f(e){
    alert("鼠标坐标 y:"+e.clientX);
    }
    </script>
    <body>
    <div style="height:1000px; background-color:red;" onclick="f(event)">
    s

    </div>
    </body>
    </html>
      

  2.   

    上边的alert("鼠标坐标 y:"+e.clientX);
    应该是 alert("鼠标坐标 y:"+e.clientY);
    手误,不好意思哈!!
      

  3.   

    window.event.clientY+document.documentElement.scrollTop