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