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


HTML onprogress属性用法及代码示例


HTML onprogress属性是事件属性,在浏览器下载指定的音频或视频时发生。

用法:

<element onprogress="myScript">

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

范例1:

<!DOCTYPE html> 
<html> 
    <head> 
        <title> 
            HTML onprogress Attribute 
        </title> 
    </head> 
  
    <body> 
        <center> 
            <h1 style="color:green;"> 
                GeeksforGeks 
            </h1> 
            <h2> 
                HTML onprogress Attribute 
            </h2> 
  
            <audio controls id="audioID" 
                   onprogress="GFGfun()"> 
                <source src= 
"https://media.geeksforgeeks.org/wp-content/uploads/20190625154540/hello-world.m4a" 
                        type="audio/mpeg" /> 
            </audio> 
  
            <script> 
                function GFGfun() { 
                    alert("audio progress"); 
                } 
            </script> 
        </center> 
    </body> 
</html>

输出:



下调媒体后:

范例2:

<!DOCTYPE html> 
<html> 
    <head> 
        <title> 
            HTML onprogress Attribute 
        </title> 
    </head> 
  
    <body> 
        <center> 
            <h1 style="color:green;"> 
                GeeksforGeks 
            </h1> 
            <h2> 
                HTML onprogress Attribute 
            </h2> 
  
            <video controls id="vidID" 
                   onprogress="GFGfun()" 
                   width="320"
                   height="240"> 
                <source src= 
"https://media.geeksforgeeks.org/wp-content/uploads/20190401140735/g4g2.mp4" 
                        type="video/mp4" /> 
            </video> 
  
            <script> 
                function GFGfun() { 
                    alert("Video progress"); 
                } 
            </script> 
        </center> 
    </body> 
</html>

输出:

后:

支持的浏览器:

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




相关用法


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