-
网页可见区域宽和高:
document.documentElement.clientWidth;(不含边框) document.documentElement.clientHeight;(不含边框)
或:
document.documentElement.offsetWidth;(包含边框)
document.documentElement.offsetHeight;(包含边框)
网页可见区域宽和高(JQuery):
$(window).width();
$(window).height();网页可见区域宽和高(包括边线):
document.body.offsetWidth;
document.body.offsetHeight;滚动条的规格(JQuery):
滚动条到顶部的距离:
$(document).scrollTop();
滚动条到左边的距离:
$(document).scrollLeft();
网页正文全文高和宽:
document.documentElement.scrollWidth;
document.documentElement.scrollHeight;
或:
document.body.scrollWidth;
document.body.scrollHeight;
其中body宽度默认未设置;网页文档高和宽(JQuery):
$(document).width();
$(document).height();
或(获取body规格):
$(document.body).width();
$(document.body).height();当前屏幕分辨率的规格:
window.screen.height;
window.screen.width;屏幕可用区域规格:
window.screen.availHeight;
window.screen.availWidth;当前屏幕设置:
色位:
window.screen.colorDepth;
像素/英寸:
window.screen.deviceXDPI;获取或设置元素的规格:
$(obj).width();
$(obj).height();
注:根据W3C标准的不同,方法获取的内容可能会产生差异,详细请调试;
IE6下部分方法会产生较大偏差;