zoukankan      html  css  js  c++  java
  • scroll

    var fScrollTopHeight = function(){
    return document.documentElement&&document.documentElement.scrollTop || document.body && document.body.scrollTop || 0;
    };
    var fClientHeight = function(){
    var clientHeight=0;
    if(document.body.clientHeight&&document.documentElement.clientHeight){
    clientHeight = (document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
    }else{
    clientHeight = (document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
    }
    return clientHeight;
    };
    var fBodyHeight = function(){
    return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
    };
    $(function(){
    var fixedbar = document.getElementById("fixedbar");
    // jScShow = $('<div style="position:fixed;bottom:100px;right:0;z-index:999;background:red;120px;height:100px;">5555</div>').appendTo('body');
    $(document).on('scroll', function(){
    // alert(1);
    // jScShow.html([fScrollTopHeight(), fClientHeight(), fBodyHeight()].join('<BR /><BR />') + '<BR />');

    // if(fScrollTopHeight()+fClientHeight()- fBodyHeight() >= -10){//最底部

    // }


    var items = $("#wrapper").find('.ui-coll-list');
    var currentText = "";
    items.each(function(){
    var m = $(this);
    if (fScrollTopHeight() > m.offset().top - 86) {
    currentText = m.find('.head').text();
    }else{
    return false
    }
    });
    if (currentText) {
    fixedbar.innerHTML = currentText;
    };

    if (fScrollTopHeight() > 5) {
    fixedbar.style.display="block";
    }else{
    fixedbar.style.display="none";
    }
    });
    })

  • 相关阅读:
    SQL大语句——实现分页,select top后面跟变量出错
    jQuery异步请求(如getJSON)跨域解决方案
    Debug常用命令
    清华操作系统实验--80x86汇编基础
    在Windows10中运行debug程序
    恢复Windows10应用商店
    最少硬币问题
    嵌套矩形问题
    清华大学操作系统实验准备--挖坑
    动态规划入门-数字三角形
  • 原文地址:https://www.cnblogs.com/nuoyiamy/p/5481674.html
Copyright © 2011-2022 走看看