html窗口(window)高度、文档(document)高度介绍
来源:互联网 发布:用友软件公司简介 编辑:程序博客网 时间:2024/06/14 07:42
今天在做滚动条监听进行分页实例时候,忽然发现html窗口(window)高度、文档(document)高度不太懂,后来通过日志打印观察各个高度才知道,现在分享经验:
窗口<$(window).height()>高度: 你的屏幕高度(你在屏幕上能看到的视角高度),而文档document<$(document).height()>高度就是你整个页面所有dom高度,因为有的页面高度太高不能再窗口中全部显示 这时候我们就需要上下滚动页面查看所有网页内容那么我们从顶端开始一直滚到到最低端 这段距离就是文档高度<$(document).height()>,下面贴出滚动条监听js代码:
$(function(){
$("#footer").hide();
$(window).scroll(function () {
//$(window).scrollTop()这个方法是当前滚动条滚动的距离
//$(window).height()获取当前窗体的高度
//$(document).height()获取当前文档的高度
var bot = 40; //bot是底部距离的高度
console.log("$(window).scrollTop():"+$(window).scrollTop());
console.log("$(document).height():"+$(document).height());
console.log("$(window).height():" +$(window).height());
if ((bot + $(window).scrollTop()) >= ($(document).height() - $(window).height())) {
//当底部基本距离+滚动的高度〉=文档的高度-窗体的高度时;
//我们需要去异步加载数据了
console.log("此时加载数据");
}
});
});
- html窗口(window)高度、文档(document)高度介绍
- 关于浏览器window、document、html、body高度的探究
- document window高度的计算
- 网页窗口window、文档body高度的获取
- html/css基础篇——关于浏览器window、document、html、body高度的探究
- html获取窗口高度宽度
- $(document).height()获取文档的高度
- 取窗口滚动条高度|取窗口可视范围的高度|取文档内容实际高度
- jQuery窗口、文档各种高度的理解
- jQuery窗口、文档各种高度的理解
- Html iframe 窗口自适应内容高度
- html/jQuery获取窗口宽度/高度
- js获取宽度 ,各种高度宽度document.body.clientWidth , document.body.clientHeight,window.screen.width 等等
- js获取宽度 ,各种高度宽度document.body.clientWidth , document.body.clientHeight,window.screen.width 等等
- jquery $(window).height()获取的不是窗口的高度解决
- $(window).height()返回的不是浏览器窗口的高度?
- window高度的获取
- 8、关于窗口和文档的几个重要的高度
- HDU 4004 The Frog's Games(2011年大连网络赛 D 二分+贪心)
- 为什么short类型取值范围为-32768~32767
- 【OVS2.5.0源码分析】datapath之主流程分析
- codeforces C.Coloring Trees
- OC-UIButton
- html窗口(window)高度、文档(document)高度介绍
- 介绍 Android 的 Camera 框架
- Cookie的基本使用
- Linux Shell脚本攻略:基础入门
- CUDA学习--图形互操作(CUDA与OpenGL的交互)
- A.Bus to Udayland
- 源码-spark的ListenerBus体系
- 基于Spark mllib的矩阵分解(ALS)推荐算法
- jQuery筛选器知识