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


HTML onloadstart屬性用法及代碼示例

HTML onloadstart屬性是事件屬性,在指定音頻/視頻的加載過程開始時發生。

用法:

<element onloadstart="myScript">

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

例:

<!DOCTYPE html>  
<html>  
  
<head>  
    <title>  
        HTML  onloadstart Attribute  
    </title>  
</head>  
  
<body>  
    <center>  
        <h1 style="color:green">  
        GeeksforGeeks  
    </h1>  
        <h2>DOM onloadstart Attribute</h2>  
        <audio controls id="audId">  
        <source src=  
"https://media.geeksforgeeks.org/wp-content/uploads/20190625153922/frog.mp3"
        type="audio/mpeg"> 
        </audio>  
  
        <script>  
            document.getElementById(  
            "audId").addEventListener(  
            "loadstart", GFGFun);  
  
            function GFGFun() {  
                alert("Start the load audio");  
            }  
        </script>  
    </center>  
</body>  
  
</html>                    

輸出:



後:




相關用法


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