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


HTML onsuspend屬性用法及代碼示例

HTML onsuspend是事件屬性,當瀏覽器未獲取媒體數據時發生。暫停媒體加載時,會發生此事件。下載完成或由於某些中斷而被暫停時,可能會發生這種情況。

用法:用於<audio>和<video>標簽,

用法:

<element onsuspend="Script">

屬性值:此屬性包含單值腳本,該腳本在onsuspend事件屬性調用時起作用

例:



<!DOCTYPE html>  
<html>  
  
<head>  
    <title>  
        HTML onsuspend Attribute  
    </title>  
</head>  
  
<body>  
    <center>  
        <h1 style="color:green">GeeksforGeeks</h1>  
        <h2>HTML onsuspend Attribute</h2>  
  
       
        <audio controls id-"audioID">  
            <source src="beep.mp3" type="audio/mpeg">  
        </audio>  
    </center>  
    <script>  
        document.getElementById(  
            "audioID").addEventListener("suspend", GFGfun);  
  
        function GFGfun() {  
            alert(  
                "Media loading suspended");  
        }  
    </script>  
  
</body>  
  
</html> 

輸出:




相關用法


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