document.body.scrollLeft  x轴
document.body.scrollTop   y轴

解决方案 »

  1.   

    componentFromPoint Method--------------------------------------------------------------------------------Returns the component located at the specified coordinates via certain events. SyntaxsScrollComponent = object.componentFromPoint(iCoordX, iCoordY)
    ParametersiCoordX Required. Integer that specifies the client window coordinate of x. 
    iCoordY Required. Integer that specifies the client window coordinate of y. Return ValueString. Returns one of the following possible values:empty string Component is inside the client area of the object. 
    outside Component is outside the bounds of the object. 
    scrollbarDown Down scroll arrow is at the specified location. 
    scrollbarHThumb Horizontal scroll thumb or box is at the specified location. 
    scrollbarLeft Left scroll arrow is at the specified location. 
    scrollbarPageDown Page-down scroll bar shaft is at the specified location. 
    scrollbarPageLeft Page-left scroll bar shaft is at the specified location. 
    scrollbarPageRight Page-right scroll bar shaft is at the specified location. 
    scrollbarPageUp Page-up scroll bar shaft is at the specified location. 
    scrollbarRight Right scroll arrow is at the specified location. 
    scrollbarUp Up scroll arrow is at the specified location. 
    scrollbarVThumb Vertical scroll thumb or box is at the specified location. 
    handleBottom Bottom sizing handle is at the specified location. 
    handleBottomLeft Lower-left sizing handle is at the specified location. 
    handleBottomRight Lower-right sizing handle is at the specified location. 
    handleLeft Left sizing handle is at the specified location. 
    handleRight Right sizing handle is at the specified location. 
    handleTop Top sizing handle is at the specified location. 
    handleTopLeft Upper-left sizing handle is at the specified location. 
    handleTopRight Upper-right sizing handle is at the specified location. 
      

  2.   

    <HTML>
    <HEAD>
    <SCRIPT>
    /*When this function is activated, an alert pops up displays the component at the position of the pointer. */
    function ComponentSnapShot(){
       var sElem = "";
       sElem = document.body.componentFromPoint(
          event.clientX,
          event.clientY
       );
       if (sElem=="")
        alert("No component there!");
       else
        alert("Component: " + sElem);    
    }function trackElement(){
       var sElem = "";
       sElem = document.body.componentFromPoint(
          event.clientX,
          event.clientY
       );
       window.status = "mousemove " + event.clientX + ", "
          + event.clientY +
          " The mouse pointer is hovering over: " + sElem;
       
    }
    </SCRIPT>
    </HEAD>
    <!-- There are several different events that can be used with componentFromPoint. Below are a few of them. 
    Be carefull! Not all mouse events can be used with componentFromPoint.  -->
    <BODY onmousemove="trackElement()" onmousedown="ComponentSnapShot()" onkeydown="ComponentSnapShot()" oncontextmenu="ComponentSnapShot()">
    <TEXTAREA COLS=500 ROWS=500>
    This text forces scroll bars to appear in the window.
    </TEXTAREA>
    </BODY>
    </HTML>
    看例子得状态栏得变化
      

  3.   

    <HTML>
    <HEAD>
    <SCRIPT>
    /*When this function is activated, an alert pops up displays the component at the position of the pointer. */
    function ComponentSnapShot(){
       var sElem = "";
       sElem = document.body.componentFromPoint(
          event.clientX,
          event.clientY
       );
       if (sElem=="")
        alert("No component there!");
       else
        alert("Component: " + sElem);    
    }function trackElement(){
       var sElem = "";
       sElem = document.body.componentFromPoint(
          event.clientX,
          event.clientY
       );
       window.status = "mousemove " + event.clientX + ", "
          + event.clientY +
          " The mouse pointer is hovering over: " + sElem;
       
    }
    </SCRIPT>
    </HEAD>
    <!-- There are several different events that can be used with componentFromPoint. Below are a few of them. 
    Be carefull! Not all mouse events can be used with componentFromPoint.  -->
    <BODY onmousemove="trackElement()" onmousedown="ComponentSnapShot()" onkeydown="ComponentSnapShot()" oncontextmenu="ComponentSnapShot()">
    <TEXTAREA COLS=500 ROWS=500>
    This text forces scroll bars to appear in the window.
    </TEXTAREA>
    </BODY>
    </HTML>
    看例子得状态栏得变化
      

  4.   

    我是想拖动body的滚动条,不是textArea的,你这个例子没有告诉我在onScroll里怎么判断呀??!
      

  5.   

    <body onscroll="test()">
    000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    <script>
    for(var i=0;i<100;i++)
    {
        document.write(i+"<br>");
    }var T = document.body.scrollTop;
    var L = document.body.scrollLeft;
    function test()
    {
        if(T!=document.body.scrollTop)alert("Y轴");
        if(L!=document.body.scrollLeft)alert("X轴");
        T = document.body.scrollTop;
        L = document.body.scrollLeft;
    }
    </script>