<!DOCTYPE html>
<html><head><meta charset="utf-8" /></head><body><p id="demo"></p><script>//Part I 取浏览器内部窗口宽度及高度//该例显示浏览器窗口的高度和宽度:(不包括工具栏/滚动条)var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;var x1 = "浏览器内部窗口宽度:" + w + ",高度:" + h + "。<br /><br />";//Part II 去浏览器外部窗口宽度及高度//screen.availWidth 属性返回访问者屏幕的宽度,以像素计,减去界面特性,比如窗口任务栏。//screen.availHeight 属性返回访问者屏幕的高度,以像素计,减去界面特性,比如窗口任务栏。var x2 = "浏览器外部窗口宽度:" + screen.availWidth + ",高度:" + screen.availHeight + "。<br />";document.getElementById("demo").innerHTML = x1 + x2;</script></body>
</html>