上货精灵+改价精灵原创作者,旺宝软件官网www.58wangbao.com首席设计师!VX:xtfnpgy

作者有十多年的软件开发经验,长期致力于电商软件的开发,目前推出的两款软件【拼多多改价精灵】、【拼多多上货精灵】已经成为千万卖家开店必备的工具,有效解决了拼上拼、出单利润问题! 一手原创软件,请认准作者微信xtfnpgy,切勿上当受骗!

博客园 首页 新随笔 联系 订阅 管理

1.隐藏滚动条

document.documentElement.style.overflow = 'hidden';
隐藏竖向滚动条:
document.documentElement.style.overflow = 'hidden';

 

1.滚动方法

window.scrollTo(0,0);       /*滚动到顶部*/

window.scrollBy(0,100);   /*向下滚动100*/

window.scrollTo(0,document.body.scrollHeight); /*滚动到底部*/

 

2.滚动条是否滚动到底部?是,返回true;否,返回当前垂直滚动条位置。

function getScrollTop(){
  var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
  if(document.body){
    bodyScrollTop = document.body.scrollTop;
  }
  if(document.documentElement){
    documentScrollTop = document.documentElement.scrollTop;
  }
  scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
  return scrollTop;
};
function getScrollHeight(){
  var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
  if(document.body){
    bodyScrollHeight = document.body.scrollHeight;
  }
  if(document.documentElement){
    documentScrollHeight = document.documentElement.scrollHeight;
  }
  scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
  return scrollHeight;
};
function getWindowHeight(){
  var windowHeight = 0;
  if(document.compatMode == "CSS1Compat"){
    windowHeight = document.documentElement.clientHeight;
  }else{
    windowHeight = document.body.clientHeight;
  }
  return windowHeight;

};

function IsScrollToBottom(){

  if(getScrollTop() + getWindowHeight() == getScrollHeight()){ 
    alert("true");
  } else {
     alert(getScrollTop() + getWindowHeight());
  }
}

IsScrollToBottom();

 

3./*----------1秒向下滚动一次,直至到底部---------*/
var timer = setInterval(function(){  
            window.scrollBy(0,100);  
            if(getScrollTop() + getWindowHeight() == getScrollHeight()){  
                clearInterval(timer);  
            }  

        },1000);  

 

posted on 2018-07-09 19:11  weixin_xtfnpgy  阅读(1039)  评论(0编辑  收藏  举报