页面上有垂直滚动条,发生滚动的时候,怎么获得这个滚动多少高度 ?

解决方案 »

  1.   

    window.onscroll = function(){
    alert(document.documentElement.scrollTop)
    };
      

  2.   

      getScroll = function () {//计算滚动条的位置  
            var t, l;  
            if (document.documentElement && document.documentElement.scrollTop) {  
                t = document.documentElement.scrollTop;  
                l = document.documentElement.scrollLeft;  
            } else if (document.body) {  
                t = document.body.scrollTop;  
                l = document.body.scrollLeft;  
            }  
            else {  
                t = 0; l = 0;  
            }  
            return { top: t, left: l };  
        }  
      

  3.   

    var top = document.body.scrollTop | document.documentElement.scrollTop;