event.html:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
//点击页面的任何部分
document.onclick = function (event) {
//兼容写法
event = event || window.event; //兼容写法
console.log(event);
console.log(event.timeStamp); //事件生成的日期和时间(相对页面加载完成的事件,单位秒)
console.log(event.bubbles); //返回布尔值,事件是否是起泡事件类型
console.log(event.button); //返回事件触发时,哪个鼠标按钮被点击(左键:0,中键:1)
console.log(event.pageX); //鼠标在整个网页中的X位置
console.log(event.pageY);
console.log(event.screenX); //相对屏幕(显示器)的位置
console.log(event.screenY);
console.log(event.target); //事件被传送到的对象(文档Document (this))
console.log(event.type); //事件的类型("click")
console.log(event.clientX); //在可见区域中(相对浏览器)的位置
console.log(event.clientY);
}
</script>
</body>
</html>