日期:2014-05-17  浏览次数:20592 次

html 4.01 strict标准下javascript获取页面高度和宽度尺寸的代码

注意:

doctype申明:html 4.01 strict

在搜索了很多网页之后,

经过在IE6firefox 3.0下的测试,

用js获取页面宽度高度的代码分别如下:

1、IE下:

document.body.scrollWidth;

document.body.scrollHeight;

2、Firefox下:

document.documentElement.scrollWidth;

document.documentElement.scrollHeight;

获得的尺寸是包括了页面当前显示的尺寸加上滚动条可滚动的宽度和高度。

----------------------------------------

其它页面尺寸相关的属性

网页可见区域宽: 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;?
当前鼠标位置的X坐标:document.body.scrollLeft+event.clientX; 网页横向滚动条的左位置?+ 事件源的X坐标
当前鼠标位置的Y坐标:document.body.scrollTop+event.clientY;