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;
    }
  • 相关阅读:
    文件管理后章
    文件管理前章
    文本处理三剑客
    匿名函数以及应用、三元表达式
    认识docker以及常用操作
    字符编码
    赋值与深浅拷贝
    Python基本运算符
    LVM配置
    Linux磁盘管理
  • 原文地址:https://www.cnblogs.com/ladybug7/p/12872610.html
Copyright © 2011-2022 走看看