如何在 HTML 中当浏览器因任何原因无法获取媒体数据时执行脚本?
htmlweb developmentfront end technology更新于 2024/7/31 12:28:17
在 HTML 中使用 onstalled 属性,当浏览器无法获取媒体数据时执行脚本。
onstalled 属性可用于以下元素 −
<video> <audio>
以下是 <video> 的语法 −
<video onstalled ="script">
以下是 <video> 的语法−
<audio onstalled = "script">
示例
您可以尝试运行以下代码来实现 onstalled 属性 −
<!DOCTYPE HTML>
<html>
<body>
<video width = "300" height = "200" controls onstalled ="display()">
<source src = "/html5/foo.ogg" type = "video/ogg" />
<source src = "/html5/foo.mp4" type = "video/mp4" />
Your browser does not support the video element.
</video>
<script>
function display()
{
alert ("Sorry! Video isn't available right now!");
}
</script>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

