window对象 的一些属性功能

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
</head>
<script type="text/javascript">
(function()
{
document.write("浏览器的文档区域大小:");
document.write(window.innerWidth + "," + window.innerHeight + "<br />");

document.write("浏览器的窗口大小:");
document.write(window.outerWidth + "," + window.outerHeight + "<br />");

document.write("浏览器窗口左上在屏幕中的位置:");
document.write(window.screenLeft+ "," + window.screenTop + "<br />");
})();
</script>

<body>
window.innerWidth window.innerHeight 获取文档区的大小
window.outerWidth window.outerHeight 获取窗口大小
window.screenLeft window.screenTop 获取浏览器窗口的位置

 可以改变窗口大小后刷新窗口查看数据变化
</body>

</html>

.........................

浏览器的文档区域大小:1143,735
浏览器的窗口大小:1159,827
浏览器窗口左上在屏幕中的位置:60,0
window.innerWidth window.innerHeight 获取文档区的大小 
window.outerWidth window.outerHeight 获取窗口大小
window.screenLeft window.screenTop 获取浏览器窗口的位置

innerWidth 和innerHeight 属性代表文档区的高和宽,以像素为单位,文档区是指浏览器窗口中可显示网页内容部分,不包括菜单栏,状态栏,地址栏等区域。

outerWidth 和outerHeight 属性代表整个浏览器窗口的宽和高,以像素为单位。

screenLeft 和screenTop 属性代表浏览器窗口左上角在屏幕中的坐标。

原文地址:https://www.cnblogs.com/wxhhts/p/7803762.html