doc.documentElement.scrollLeft||doc.body.scrollLeft//这个是为了兼容FF和IEwnd = wnd || window; //这个也一样

解决方案 »

  1.   

    貌似ff,ie下 doc.documentElement.scrollLeft的根元素都是html噢
    既然都取的到跟元素  干嘛还要这个doc.body.scrollLeft了  不明白。
      

  2.   

    如果是XHTML 直接用documentElement.scrollLeft就行了
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
     <title>Rank's HTML document</title>
     <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
     <meta http-equiv="Pragma" content="no-cache" /> 
     <meta http-equiv="Cache-Control" content="no-cache" /> 
     <meta http-equiv="Expires" content="0" />
     <meta http-equiv="ImageToolbar" content="no" />
     <style type="text/css" title="default" media="screen">
     /*<![CDATA[*/
     
     /*]]>*/
     </style>
     </head>
     <body>
     <div id="demo">鼠标按下,并拖动,可看到参数 <a href="http://www.never-online.net">never-online, rank</a></div>
     <script type="text/javascript">
     //<![CDATA[
     function getDocRect (wnd) {
     wnd = wnd || window;//判断对象,是window还是当前object
     doc = wnd.document;
     return { 
     left :doc.documentElement.scrollLeft||doc.body.scrollLeft||wnd.pageXOffset||wnd.scrollX||0, //因为调用SetCapture后你鼠标可以跑到浏览器外面
     top :doc.documentElement.scrollTop||doc.body.scrollTop||wnd.pageYOffset||wnd.scrollY||0, //。。
     width :doc.documentElement.clientWidth||doc.body.clientWidth||wnd.innerWidth||doc.width||0,//。
     height :doc.documentElement.clientHeight||doc.body.clientHeight||wnd.innerHeight||doc.height||0 //。
     }
     };
     var c = 0; var b = false;
     var d = document.getElementById("demo");
     document.onmousedown = function () {
     d.innerHTML = 'down'; b = true;
     if (d.setCapture) d.setCapture();//调用SetCapture后,即使鼠标移动出客户区,你也可以接受到鼠标消息。下面用GetCapture可以知道当前哪个窗口调用了SetCapture document.onmousemove = function (evt) {
     if (!b) return;
     evt = evt || window.event; //为了兼容FF
     var x, y;
     var rect = getDocRect();//获取哪个窗口调用了SetCapture
     x = evt.clientX;
     y = evt.clientY;
     window.defaultStatus = 'x:' +x+ ',y:' +y+ ' -- w:' +rect.width+ ',h:' +rect.height+ ',l:' +rect.left+ ',t:' +rect.top;
     if (x>=rect.width || y>=rect.height
     || 0>=x || 0>=y) {
     return;
     } 
     d.innerHTML = c++;
     };
     document.onmouseup = function () {
     if (!b) return;
     if (document.releaseCapture) document.releaseCapture();//松开鼠标ReleaseCapture释放setCapture。
     document.onmousemove = null;
     d.innerHTML = 'up';
     b = false;
     }
     }
     //]]>
     </script>
     </body>
    </html>
      

  4.   

    貌似没把问题说清楚  恩  重新说一下  大概有4个问题
    1.doc.documentElement.scrollLeft||doc.body.scrollLeft
    ie ff下 通过doc.documentElement.scrollLeft都是可以去到根元素html的
    所以了我就觉得后面的doc.body.scrollLeft是不是多余了  (这2个东西的大小是不是相等的??? - -!我也不清楚)2.wnd.pageYOffset 这个是啥意思(我可是先baidu google了的,但是没找到明确的解释)3。wnd.innerWidth又是什么意思  (这个没查)4.为什么最后要有一个0 (貌似按3楼的解释可以理解的通)
      

  5.   

    pageXOffset莫非是所传对象里自己定义的参数