在html里,width与height是最常用也是最基础的两个属性,因此,在js里,我们也经常需要操作这两个属性。js关于这两个属性提供了client*,offset*与scroll*,很多同学搞不清楚这三者之间的区别,经常望着这三个属性满脸问号,不知道该用哪个。所以今天就来看一下这三个属相的区别。 ...
分类:
其他好文 时间:
2016-08-30 18:02:16
阅读次数:
168
IEdocument.documentElement.scrollHeight 浏览器所有内容高度 ,document.body.scrollHeight 浏览器所有内容高度document.documentElement.scrollTop 浏览器滚动部分高度,document.body.scro ...
分类:
其他好文 时间:
2016-08-28 23:40:20
阅读次数:
158
一、客户区大小ClientWidth和ClientHeight 二、ScrollWidth/scrollHeight scrollTop/scrollLeft(这两个是相对于定位了的父盒子而言的) 三、拖拽盒子分析: 思路分析:准备工作:先获得大盒子的(上图黑色边框内) id(box) 再获得注册信 ...
分类:
Web程序 时间:
2016-08-16 00:17:01
阅读次数:
355
var scrollHeight = obj.offsetTop; clearInterval(obj.timer); obj.timer = setInterval(function(){ var bodyScroll = document.documentElement.scrollTop || ...
分类:
其他好文 时间:
2016-08-15 20:25:16
阅读次数:
98
1. offsetParent 获取的最近的定位的父元素 offsetLeft/offsetTop 是相对于offsetParent的距离 offsetHeight/offsetWidth 获取盒子的大小 border + height + padding 2 scrollHeight 滚动内容的高 ...
分类:
Web程序 时间:
2016-08-15 01:22:44
阅读次数:
181
JS控制滚动条的位置:window.scrollTo(x,y); 竖向滚动条置顶 window.scrollTo(0,0);竖向滚动条置底 window.scrollTo(0,document.body.scrollHeight) JS控制TextArea滚动条自动滚动到最下部 document.g ...
分类:
Web程序 时间:
2016-08-01 19:41:04
阅读次数:
471
HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth scrollHeight: 获取对象的滚动高度。 scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离 scrollTop:设置或获取位于对象最顶端和窗口中 ...
分类:
Web程序 时间:
2016-07-15 09:29:51
阅读次数:
378
IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.documentElement.clientWidth ==> 可见区域宽度 document.documentE ...
分类:
编程语言 时间:
2016-07-13 13:51:38
阅读次数:
182
document.body.scrollHeight 整个网页的高度 // 对应jquery的$(document).height(); document.body.offsetHeight 整个body的高度 // 对应jquery的$(document.body).height(); docum ...
分类:
Web程序 时间:
2016-06-24 12:43:10
阅读次数:
135
<textarea name="mytextarea" cols="100" style="min-height:200px" onpropertychange="this.style.height=this.scrollHeight+'px';" oninput="this.style.heigh ...
分类:
其他好文 时间:
2016-06-22 14:07:34
阅读次数:
120