function size(){ document.write( 屏幕分辨率为:+screen.width+*+screen.height +<br />+ 屏幕可用大小:+screen.availWidth+*+screen.availHeight +<br />+ 网页可见区域宽:+document.body.clientWidth +<br />+ 网页可见区域高:+document.body.clientHeight +<br />+ 浏览器窗口宽:+document.documentElement.clientWidth +<br />+ 浏览器窗口高:+document.documentElement.clientHeight +<br />+ html所有元素宽:+document.documentElement.offsetWidth +<br />+ html所有元素高:+document.documentElement.offsetHeight +<br />+ 网页可见区域宽(包括边线的宽):+document.body.offsetWidth +<br />+ 网页可见区域高(包括边线的宽):+document.body.offsetHeight +<br />+ 网页正文全文宽:+document.body.scrollWidth +<br />+ 网页正文全文高:+document.body.scrollHeight +<br />+ 网页被卷去的高:+document.body.scrollTop +<br />+ 网页被卷去的左:+document.body.scrollLeft +<br />+ 网页正文部分上:+window.screenTop +<br />+ 网页正文部分左:+window.screenLeft +<br />+ 屏幕分辨率的高:+window.screen.height +<br />+ 屏幕分辨率的宽:+window.screen.width +<br />+ 屏幕可用工作区高度:+window.screen.availHeight +<br />+ 屏幕可用工作区宽度:+window.screen.availWidth ); }
补充下,关于html dom元素都有一些关于位置,尺寸大小的属性,如下
offsetWidth | clientWidth | scrollWidth |
offsetHeight | clientHeight | scrollHeight |
offsetLeft | clientLeft | scrollLeft |
offsetTop | clientTop | scrollTop |
1. clientHeight和clientWidth用于描述元素内尺寸,是指 元素内容+内边距 大小,不包括边框(IE下实际包括)、外边距、滚动条部分
2. offsetHeight和offsetWidth用于描述元素外尺寸,是指 元素内容+内边距+边框,不包括外边距和滚动条部分
3. clientTop和clientLeft返回内边距的边缘和边框的外边缘之间的水平和垂直距离,也就是左,上边框宽度
4. offsetTop和offsetLeft表示该元素的左上角(边框外边缘)与已定位的父容器(offsetParent对象)左上角的距离
相信看了本文案例你已经掌握了方法,更多精彩请关注编程之家网其它相关文章!
推荐阅读: