兼容各浏览器的

解决方案 »

  1.   

    //获取滚动条高度   
    function getScrollTop() {   
        var scrollPos = 0;    
        if (typeof window.pageYOffset != 'undefined') {    
           scrollPos = window.pageYOffset;    
        }    
        else if (typeof window.document.compatMode != 'undefined' &&    
           window.document.compatMode != 'BackCompat') {    
           scrollPos = window.document.documentElement.scrollTop;    
        }    
        else if (typeof window.document.body != 'undefined') {    
           scrollPos = window.document.body.scrollTop;    
        }    
        return scrollPos;   
    }  
      

  2.   

    var geometry={};
    if(window.innerWidth){ // 除了IE
      geometry.getHScroll=function(){
      return window.pageXOffset;
      }
      geometry.getVScroll=function(){
      return window.pageYOffset;
      }
    }else if(document.documentElement && document.documentElement.clientWidth){ //有定义DOCTYPE 的 IE 6
      geometry.getHScroll=function(){
      return document.documentElement.scrollLeft;
      }
      geometry.getVScroll=function(){
      return document.documentElement.scrollTop;
      }
    }else if(document.body.clientWidth){ //没有定义DOCTYPE的其它IE版本
      geometry.getHScroll=function(){
      return document.body.scrollLeft;
      }
      geometry.getVScroll=function(){
      return document.body.scrollTop;
      }
    }别人以前写的,给你用吧
      

  3.   

    <body style="height:1000px;">这个返回是0