(document).height()与$(window).height()

jQuery(window).height()代表了当前可见区域的大小,而jQuery(document).height()则代表了整个文档的高度,可视具体情况使用.

注意当浏览器窗口大小改变时(如最大化或拉大窗口后) jQuery(window).height() 随之改变,但是jQuery(document).height()是不变的。

$(document).scrollTop() 获取垂直滚动的距离  即当前滚动的地方的窗口顶端到整个页面顶端的距离$(document).scrollLeft() 这是获取水平滚动条的距离

要获取顶端 只需要获取到scrollTop()==0的时候  就是顶端了

要获取底端 只要获取scrollTop()>=$(document).height()-$(window).height()  就可以知道已经滚动到底端了

$(document).height()  //是获取整个页面的高度$(window).height()  //是获取当前 也就是你浏览器所能看到的页面的那部分的高度  这个大小在你缩放浏览器窗口大小时 会改变 与document是不一样的  根据英文应该也能理解吧

自己做个实验就知道了 $(document).scroll(function(){    $("#lb").text($(document).scrollTop());})<span id="lb" style="top:100px;left:100px;position:fixed;"></span><!--一个固定的span标记 滚动时方便查看-->
时间: 2024-08-26 15:34:52

(document).height()与$(window).height()的相关文章

$(document).height()、$(&quot;body&quot;).height()、$(window).height()区别和联系

前言:在此以高度为示例,宽度问题可类推.在移动端开发中,经常遇到需要把一块内容定位于底部的情况,当页面内容不满一屏时,需要设为fixed,而超过 一屏时,需要设为static随页面顶到底部,此时就需要通过判断$(document).height()和$(window).height()的大 小来区分内容是否超屏. $(document):整个文档 $("body"):body $(window):视口(有设doctype的前提下) 1).页面内容大于视口(浏览器窗口)时:$(docum

网页上弹出pop窗口实例,(document).height()与$(window).height()的区别

#dvbg{background-color:#666666; position:absolute; z-index:99; left:0; top:0; display:none; width:100%; height:1000px;opacity:0.5;filter: alpha(opacity=50);-moz-opacity: 0.5;}        #dvpop{position:absolute;display:none;width:auto; height:auto; z-in

$(document).height 与$(window).height的区别

$(document).scrollTop() 获取垂直滚动的距离 (即当前滚动的地方的窗口顶端到整个页面顶端的距离)$(document).scrollLeft() 这是获取水平滚动条的距离 要获取顶端 只需要获取到scrollTop()==0的时候 就是顶端了 要获取底端 只要获取scrollTop()>=$(document).height()-$(window).height() 就可以知道已经滚动到底端了 注意:$(window).height() 和 $(document).heig

(document).height()与$(window).height()的区别,以及如何判断滚动条是否触顶或触底

jQuery(window).height()代表了当前可见区域的大小,而jQuery(document).height()则代表了整个文档的高度,可视具体情况使用. 注意当浏览器窗口大小改变时(如最大化或拉大窗口后) jQuery(window).height() 随之改变,但是jQuery(document).height()是不变的. $(document).scrollTop() 获取垂直滚动的距离 即当前滚动的地方的窗口顶端到整个页面顶端的距离$(document).scrollLef

$(window).height() 文档高度问题

遇到一个这样的问题: 有个项目做的好好的,测试时一步一步小心过来,做了一段时间后,发现前面的完成的功能出了问题了 首先描述下出问题的功能: 做滚动条下拉加载的时候用的网上找的一种方法 $(window).scroll(function(){ if($(document).scrollTop()>=$(document).height()-$(window).height()){ alert("aa"); } }); 当我们出现滚动条时,把滚动条下拉就可以产生事件,这样我们就可以在

$(window).height()取值等于$(document).height()的问题

今天一个同事反映公司网站的弹窗跑到网页底部去了,检查JS代码,测试发现文件中$(window).height()取得的值竟然等于$(document).height().百思不得其解,百度找到一篇文章说webkit内核下,如果使用的是html5格式的文档声明,则会出现这种情况,文章介绍的方法是将原来的文档声明改为: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.

document.documentElement.clientHeight 和 $(window).height() 无法正确获取页面可视区高度

背景: 弹出层插件(自适应) 实现过程中突然发现在获取可视区高度时,无论document.documentElement.clientHeight 还是 $(window).height()都无法正确获取,代码没有问题: 解决方案:通过 cosole.log寻找错误点发现$(window).height()获取不正常并等于$(document).height():网上查找资料是由于没有正确的HTML5文档声明导致的 正确: <!DOCTYPE html> <html> <!-

jQuery,javascript获得网页的高度和宽度$(document).height / $(window).height

一.javascript 网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeight 网页可见区域宽: document.body.offsetWidth (包括边线的宽) 网页可见区域高: document.body.offsetHeight (包括边线的高) 网页正文全文宽: document.body.scrollWidth 网页正文全文高: document.body.scrollHeight 网页被卷去的

jQuery下 $(window)和$(document)的width、height方法值得区别

在没有垂直滚动条的时候 $(window)和$(document) 的宽高一致在有垂直滚动条的时候 $(window)和$(document) 的宽度一致 window的高度为可视区域的高度,document为整个html文档的高度(包含margin padding border就是总的) 在没有水平滚动条的时候 $(window)和$(document) 的宽高一致在有水平滚动条的时候 $(window)和$(document) 的高度一致window的宽度为可视区域的宽度,document