<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>获得网页可见区域宽度</title>
<script type="text/javascript">
function show() {
var s = "";
s += "网页可见区域宽度:" + document.body.clientWidth;
s += "\n网页可见区域高度:" + document.body.clientHeight;
s += "\n网页可见区域宽度(包括边线):" + document.body.offsetWidth;
s += "\n网页可见区域高度(包括边线):" + document.body.offsetHeight;
s += "\n网页正文宽度:" + document.body.scrollWidth;
s += "\n网页正文高度:" + document.body.scrollHeight;
s += "\n屏幕可用工作区域宽度:" + window.screen.availWidth;
s += "\n屏幕可用工作区域高度:" + window.screen.availHeight;
s += "\n屏幕分辨率宽度:" + window.screen.width;
s += "\n屏幕分辨率高度:" + window.screen.height;
alert(s);
}
</script>
</head>
<body style="margin:0;border:0">
<div style="width:2000px;height:90px;margin:0">
<a onclick="show()" href="#">点击</a>
<button onclick="show()">点击</button>
</div>
</body>
</html>