获取滚动条高度的方法

js 代码
  1. //获取滚动条高度   
  2. function getScrollTop() {   
  3.     var scrollPos = 0;    
  4.     if (typeof window.pageYOffset != 'undefined') {    
  5.        scrollPos = window.pageYOffset;    
  6.     }    
  7.     else if (typeof window.document.compatMode != 'undefined' &&    
  8.        window.document.compatMode != 'BackCompat') {    
  9.        scrollPos = window.document.documentElement.scrollTop;    
  10.     }    
  11.     else if (typeof window.document.body != 'undefined') {    
  12.        scrollPos = window.document.body.scrollTop;    
  13.     }    
  14.     return scrollPos;   
  15. }  
posted @ 2010-10-24 15:57  从孑开始  阅读(719)  评论(0编辑  收藏  举报