$(document).scrollTop() 获取垂直滚动的距离 即当前滚动的地方的窗口顶端到整个页面顶端的距离
要获取顶端 只需要获取到scrollTop()==0的时候 就是顶端了
要获取底端 只要获取$(document).scrollTop()>=(document).height()−(window).height() 就可以知道已经滚动到底端了
    //滚动时保存滚动位置
$(window).scroll(function(){
if($(document).scrollTop()!=0){
sessionStorage.setItem("offsetTop", $(window).scrollTop());//保存滚动位置
// $(window).scrollTop()这个方法是当前滚动条滚动的距离
}
}); window.onload = function()
{
var _offset = sessionStorage.getItem("offsetTop");
$(document).scrollTop(_offset);
console.log(_offset);
};

随机推荐

  1. xaf 修改主页logo

    https://documentation.devexpress.com/#Xaf/CustomDocument3156

  2. C#:xml操作(待补充)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.X ...

  3. C#中Out和Ref參数修饰符

    在编程过程中对于函数之间的參数的传递一般分为两种:传值和传地址. 以下为大家分析一下. 传值 比方你又一份文档,假设採用传值的话.相当于我复制了一份,因此我对我这份文档的改动都不会影响到你的那份.假设 ...

  4. Repository模式(转载)

    近来发现很多ASP.NET MVC的例子中都使用了Repository模式,比如Oxite,ScottGu最近发布的免费的ASP.NET MVC教程都使用了该模式.就简单看了下. 在<企业架构模 ...

  5. spine 所有动画的第一帧必须把所有能K的都K上

    spine 所有动画的第一帧必须把所有能K的都K上.否则在快速切换动画时会出问题.

  6. HttpOperater

    using System; using System.IO; using System.Linq; using System.Net; using System.Text; using System. ...

  7. AESDK关于AEFX_CLR_STRUCT的用处

    主要是在初始化UI值的时候遇到问题,一直报错 但确实没有用到ui_width,ui_height...,仔细检查例子工程发现,少了一个AEFX_CLR_STRUCT宏 AEFX_CLR_STRUCT其 ...

  8. 动态更新highcharts数据

    <!doctype html> <html> <head> <script type="text/javascript" src=&quo ...

  9. 简单实现Spring中BeanFactory原理

    上一篇文章介绍了Java反射机制在Spring IOC中的应用,知道了BeanFactory底层的实现原理. 原理搞懂了,对Spring IOC理解起来也很容易. 先来看看Java代码获取Spring ...

  10. 16V554 的测试代码

    //------------------------------------------------------------------------ #include   "AT16C554 ...