jqery和js获取页面高度,滚动条高度

网页可见区域宽: document.body.clientWidth
网页可见区域高: document.body.clientHeight
网页可见区域宽: document.body.offsetWidth (包括边线的宽)
网页可见区域高: document.body.offsetHeight (包括边线的高)
网页正文全文宽: document.body.scrollWidth
网页正文全文高: document.body.scrollHeight
网页被卷去的高: document.body.scrollTop
网页被卷去的左: document.body.scrollLeft
网页正文部分上: window.screenTop
网页正文部分左: window.screenLeft
屏幕分辨率的高: window.screen.height
屏幕分辨率的宽: window.screen.width
屏幕可用工作区高度: window.screen.availHeight

屏幕可用工作区宽度: window.screen.availWidth

jquery

获取浏览器显示区域的高度 : $(window).height(); 
获取浏览器显示区域的宽度 :$(window).width(); 
获取页面的文档高度 :$(document).height(); 
获取页面的文档宽度 :$(document).width();

获取滚动条到顶部的垂直高度 :$(document).scrollTop(); 
获取滚动条到左边的垂直宽度 :$(document).scrollLeft();

计算元素位置和偏移量 
offset方法是一个很有用的方法,它返回包装集中第一个元素的偏移信息。默认情况下是相对body的偏移信息。结果包含 top和left两个属性。 
offset(options, results) 
options.relativeTo  指定相对计 算偏移位置的祖先元素。这个元素应该是relative或absolute定位。省略则相对body。 
options.scroll  是否把 滚动条计算在内,默认TRUE 
options.padding  是否把padding计算在内,默认false 
options.margin   是否把margin计算在内,默认true 
options.border  是否把边框计算在内,默认true

时间: 2024-08-16 15:53:12

jqery和js获取页面高度,滚动条高度的相关文章

使用js获取页面的各种高度

使用js获取相关高度: 获取网页被滚动条卷去的高度--兼容写法: scrollHeight = documen.body.scrollTop || document.documentElement.scrollTop; 获取网页全文的高度--兼容写法: windowHeight = document.body.scrollHeight || document.documentElement.scrollHeight; 获取网页可视区域的高度--兼容写法: screenHeight = docum

[转载]js 和 jquery 获取页面和滚动条的高度 视口高度文档高度

转载自:http://www.cnblogs.com/rainbow661314/p/3317106.html js 和 jquery 获取页面和滚动条的高度 //页面位置及窗口大小 function GetPageSize() { var scrW, scrH; if(window.innerHeight && window.scrollMaxY) {    // Mozilla scrW = window.innerWidth + window.scrollMaxX; scrH = w

JS获取各种宽度、高度的简单介绍

JS获取各种宽度.高度的简单介绍: scrollHeight: 获取对象的滚动高度.  scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离  scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离  scrollWidth:获取对象的滚动宽度  offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度  offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标

js 获取浏览器宽度和高度

有三种方法能够确定浏览器窗口的尺寸(浏览器的视口,不包括工具栏和滚动条 ). 对于Internet Explorer.Chrome.Firefox.Opera 以及 Safari: window.innerHeight - 浏览器窗口的内部高度 window.innerWidth - 浏览器窗口的内部宽度 对于 Internet Explorer 8.7.6.5: document.documentElement.clientHeight document.documentElement.cli

JS获取各种宽度、高度的简单介绍:

JS获取各种宽度.高度的简单介绍: scrollHeight: 获取对象的滚动高度. scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离 scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离 scrollWidth:获取对象的滚动宽度 offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度 offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧

JS 获取各个宽度和高度

IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.documentElement.clientWidth ==> 可见区域宽度 document.documentElement.clientHeight ==> 可见区域高度 FireFox中: document.body.clientWidth ==> BODY对象宽度 document.b

js获取网页的各种高度

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

js获取页面的宽度

JS如何获取屏幕浏览器网页高度宽度网页可见区域宽:document.body.clientWidth网页可见区域高:document.body.clientHeight网页可见区域宽:document.body.offsetWidth (包括边线的宽)网页可见区域高:document.body.offsetHeight (包括边线的宽)网页正文全文宽:document.body.scrollWidth网页正文全文高:document.body.scrollHeight网页被卷去的高:docume

js获取页面元素位置函数(跨浏览器)

function getElementPos(elementId) { var ua = navigator.userAgent.toLowerCase(); var isOpera = (ua.indexOf('opera') != -1); var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof var el = document.getElementById(elementId); if(el.par