當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


HTML view Event用法及代碼示例

視圖事件屬性用於返回對Window對象的引用。當事件發生時,它返回窗口對象的引用。

用法:

event.view

返回值:返回對Window對象的引用。


以下示例程序旨在說明視圖事件屬性:

<!DOCTYPE html> 
<html> 
  
<head> 
    <title>view Event Property in HTML</title> 
    <style> 
        h1 { 
            color:green; 
        } 
          
        h2 { 
            font-family:Impact; 
        } 
          
        body { 
            text-align:center; 
        } 
    </style> 
</head> 
  
<body> 
  
    <h1>GeeksforGeeks</h1> 
    <h2>view Event Property</h2> 
  
    <p>For returning a reference to the Window object, 
      double click the "Return Reference" button:</p> 
  
    <button ondblclick="myevent(event)">Return Reference</button> 
    <br> 
  
    <p id="test"></p> 
  
    <script> 
        function myevent() { 
            var e = event.view; 
            document.getElementById("test").innerHTML = e; 
        } 
    </script> 
  
</body> 
  
</html> 
               

輸出:

單擊按鈕後

支持的Web瀏覽器:

  • Opera
  • IE瀏覽器
  • 穀歌瀏覽器
  • Firefox
  • 蘋果Safari


相關用法


注:本文由純淨天空篩選整理自Shubrodeep Banerjee大神的英文原創作品 HTML | view Event Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。