当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


HTML onloadeddata属性用法及代码示例

HTML onloadeddata属性是事件属性,当加载当前帧数据但下一帧的数据不足以播放音频/视频时,会发生此事件。

用法:

<element onloadeddata="myScript">

属性值:此属性包含单值脚本,该脚本在调用onloadeddata事件属性时起作用。 <audio>和<video>标签支持此属性。

范例1:

<!DOCTYPE html> 
<html> 
    <head> 
        <title> 
            HTML onloadeddata Attribute 
        </title> 
    </head> 
  
    <body> 
        <center> 
            <h1 style="color:green;"> 
                GeeksforGeeks 
            </h1> 
            <h2> 
                HTML onloadeddata Attribute 
            </h2> 
            <audio controls id="audioId" 
                   onloadeddata="GFGfun()"> 
                <source src= 
"https://media.geeksforgeeks.org/wp-content/uploads/20190625153922/frog.mp3"
                        type="audio/mpeg" /> 
            </audio> 
  
            <script> 
                function GFGFun() { 
                    alert( 
                "Browser has loaded the current frame"); 
                } 
            </script> 
        </center> 
    </body> 
</html>

输出:



后:

范例2:

<!DOCTYPE html> 
<html> 
    <head> 
        <title> 
            HTML onloadeddata Attribute 
        </title> 
    </head> 
  
    <body> 
        <center> 
            <h1 style="color:green;"> 
                GeeksforGeeks 
            </h1> 
            <h2> 
                HTML onloadeddata Attribute 
            </h2> 
            <video controls id="VideoId" 
                   width="320" 
                   height="240"
                   onloadeddata="GFGfun()"> 
              <source src= 
"https://media.geeksforgeeks.org/wp-content/uploads/20190401140735/g4g2.mp4" 
                      type="video/mp4" /> 
          </video> 
  
         <script> 
          function GFGFun() { 
            alert("Browser has loaded the current frame"); 
          } 
            </script> 
        </center> 
    </body> 
</html>

输出:

后:

支持的浏览器:

  • 谷歌浏览器
  • IE浏览器
  • Firefox
  • 苹果Safari
  • Opera




相关用法


注:本文由纯净天空筛选整理自ManasChhabra2大神的英文原创作品 HTML onloadeddata Attribute。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。