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 物件−

更新於: 2021-2-16

83 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始
頁面廣告
© . All rights reserved.