HTML 视图事件属性
HTML 视图事件属性会返回一个指向事件发生所在 Window 对象的引用。
语法
以下是语法−
event.view
示例
我们来看看 HTML 视图事件属性示例−
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #FBAB7E;
background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
text-align: center;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
</style>
<body>
<h1>HTML view Event Property</h1>
<button class="btn" onclick="get()">Show view event</button>
<div class="show"></div>
<script>
function get() {
document.querySelector(".show").innerHTML = "Open your console and observe the Window object";
console.log(event.view);
}
</script>
</body>
</html>输出

单击“展示视图事件”按钮以展示 Window 对象−

现在打开你的控制台以观察 Window 对象−

页面广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP