JQuery 窗口尺寸:
console.log($(window).height()); //浏览器时下窗口可视区域高度
console.log($(document).height()); //浏览器时下窗口文档的高度
console.log($(document.body).height());//浏览器时下窗口文档body的高度
console.log($(document.body).outerHeight(true));//浏览器时下窗口文档body的总高度 包括border padding margin
console.log($(window).width()); //浏览器时下窗口可视区域宽度
console.log($(document).width());//浏览器时下窗口文档对于象宽度
console.log($(document.body).width());//浏览器时下窗口文档body的高度
console.log($(document.body).outerWidth(true));//浏览器时下窗口文档body的总宽度 包括border padding margin
console.log($(document).scrollTop()); //获取滚动条到顶部的垂直高度
console.log($(document).scrollLeft()); //获取滚动条到左边的垂直宽度
Javascript:
IE中:document.body.clientWidth ==> BODY对象宽度document.body.clientHeight ==> BODY对象高度document.documentElement.clientWidth ==> 可见区域宽度document.documentElement.clientHeight ==> 可见区域高度FireFox中:document.body.clientWidth ==> BODY对象宽度document.body.clientHeight ==> BODY对象高度document.documentElement.clientWidth ==> 可见区域宽度document.documentElement.clientHeight ==> 可见区域高度Opera中:document.body.clientWidth ==> 可见区域宽度document.body.clientHeight ==> 可见区域高度document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
alert(document.body.clientWidth); //网页可见区域宽(body)
alert(document.body.clientHeight); //网页可见区域高(body)
alert(document.body.offsetWidth); //网页可见区域宽(body),包括border、margin等
alert(document.body.offsetHeight); //网页可见区域宽(body),包括border、margin等
alert(document.body.scrollWidth); //网页正文全文宽,包括有滚动条时的未见区域
alert(document.body.scrollHeight); //网页正文全文高,包括有滚动条时的未见区域
alert(document.body.scrollTop); //网页被卷去的Top(滚动条)
alert(document.body.scrollLeft); //网页被卷去的Left(滚动条)
alert(window.screenTop); //浏览器距离Top
alert(window.screenLeft); //浏览器距离Left
alert(window.screen.height); //屏幕分辨率的高
alert(window.screen.width); //屏幕分辨率的宽
alert(window.screen.availHeight); //屏幕可用工作区的高
alert(window.screen.availWidth); //屏幕可用工作区的宽
需要提一下:CSS中的margin属性,与clientWidth、offsetWidth、clientHeight、offsetHeight均无关
时间是一个好东西,记录的是爱你的证据
转载于:https://www.cnblogs.com/bore/p/9050778.html
相关资源:数据结构—成绩单生成器