<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>window对象</title>
<style>
body {
margin: 0;
width: 2000px;
height:3000px;
background: red;
}
</style>
<script>
// 网页加载完成(包括资源)
window.onload = function () {
var oDiv = document.getElementById('xxx')
//alert(oDiv.innerText)
//document.title = '标题'
//document.write(window.innerWidth + '<br />')
//document.write(window.innerHeight + '<br />')
//窗口尺寸,包括滚动条
//document.title = window.innerWidth + 'x' + window.innerHeight
// 客户端净页面宽高(H5标准)
document.title = document.documentElement.clientWidth + 'x' + document.documentElement.clientHeight
// 客户端净页面宽高(非H5标准)
//document.title = document.body.clientWidth + 'x' + document.body.clientHeight
}
// 窗口滚动事件
window.onscroll = function () {
// 页面滚动偏移(H5标准)
document.title = document.documentElement.scrollTop + 'x' + document.documentElement.scrollLeft
// 页面滚动偏移(非H5标准)
//document.title = document.body.scrollTop + 'x' + document.body.scrollLeft
}
// 窗口尺寸改变
window.onresize = function () {
document.title = document.documentElement.clientWidth + 'x' + document.documentElement.clientHeight
}
</script>
</head>
<body>
<div id="xxx">测试内容</div>
</body>
</html>