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


HTML onpause屬性用法及代碼示例

HTML onpause屬性是一個事件屬性,當用戶暫停音頻時,它將自動暫停或停止。

用法:此屬性在<audio>和<video>標簽中使用。

屬性值:該屬性包含單值腳本,該腳本在調用onpaused事件屬性時起作用。 <audio>和<video>標簽支持此屬性。

用法:

<element onpause="myScript">

例:



<!DOCTYPE html>  
<html>  
  
<head>  
    <title>  
        HTML onpause Attribute  
    </title>  
</head>  
  
<body> 
     <center>  
    <h1>  
        GeeksForGeeks  
    </h1>  
    <h1 style="color:green">  
    HTML onpause Attribute  
</h1>  
 <video controls id="geeks">  
            <source src="Geekfun.mp4"
                    type="video/mp4">  
        </video> 
      
    <script>  
        var aud =  
            document.getElementById("geeks");  
        aud.onpause = function() {  
            alert("video is paused now");  
        };  
    </script>  
</body>  
  
</html>

輸出:





相關用法


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