zoukankan      html  css  js  c++  java
  • jQuery简单的上拉加载

    $(window).scroll(function() {
          var scrollTop = $(this).scrollTop(); //滚动条距离顶部的高度
          var scrollHeight = $(document).height(); //当前页面的总高度
          var clientHeight = $(this).height(); //当前可视的页面高度
          if (scrollTop + clientHeight >= scrollHeight - 50) {
             getData(); // 请求数据
          }
    })  


    window.onscroll = function() {
      //获取被卷去高度
      var scrollTop = document.body.scrollTop;
      //获取窗口高度(可见区域高度)
      var windowHeight = document.documentElement.clientHeight;
      //获取文档高度
      var documentHeight = document.body.scrollHeight;
      if (scrollTop + windowHeight >= documentHeight - 50) {
        $('#nomore').show();
      //发送Ajax请求获取分页数据
      }
    }

     
    /**
     * 得到浏览器显示的屏幕高度
     */  
    function getViewHeight() {
        if (window.innerHeight != window.undefined)
            return window.innerHeight;
        if (document.compatMode == 'CSS1Compat')
            return document.documentElement.clientHeight;
        if (document.body)
            return document.body.clientHeight;
        return window.undefined;
    }
    
    /**
     * 得到浏览器显示的屏幕宽度
     */
    function getViewWidth() {
        if (window.innerWidth != window.undefined)
            return window.innerWidth;
        if (document.compatMode == 'CSS1Compat')
            return document.documentElement.clientWidth;
        if (document.body)
            return document.body.clientWidth;
    }
  • 相关阅读:
    loaded some nib but the view outlet was not set
    指标评比
    IOS DEVELOP FOR DUMMIES
    软件测试题二
    javascript select
    DOM节点类型详解
    mysql操作
    UVA 10055
    solutions for 'No Suitable Driver Found For Jdbc'
    解决git中文乱码问题
  • 原文地址:https://www.cnblogs.com/ladybug7/p/12872610.html
Copyright © 2011-2022 走看看