HTML 5视频OnEnded事件未触发

时间:2010-05-28 00:03:40

标签: html5 html5-video jquery

我正在尝试对onended标记的HTML 5 video事件做出反应,但没有成功。在下面的代码片段中,我添加了mouseleave事件,以确保jQuery代码正确,并且该事件确实激活了alert()框。

视频播放得很好但我没有收到onended事件(我的alert()无法触发)。

在Chrome中测试,今天更新到版本5.0.375.55。

<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script>
$(document).ready(function(){
  $("#myVideoTag").bind('mouseleave onended', function(){
        alert("All done, function!");
  });
});

</script>
</head>
<body>
<video id="myVideoTag" width="640" height="360" poster="Fractal-zoom-1-04-Snowflake.jpg" controls>
    <source src="Fractal-zoom-1-04-Snowflake.mp4" type="video/mp4"></source>
    <source src="Fractal-zoom-1-04-Snowflake.ogg" type="video/ogg"></source>
</video>

<body>
<html>

2 个答案:

答案 0 :(得分:17)

确保您绑定到ended事件而不是onended,在绑定jQuery时始终保持on,例如您无法{{1} },你做.on("onclick")

如果有帮助,这里有.on("click")元素的完整可用事件列表:http://www.w3.org/2010/05/video/mediaevents.html

答案 1 :(得分:2)

我也在寻找答案。以下是jQuery移动框架的用途:

$(document).ready(function(){
  $("#idname").bind('ended', function(){
  $.mobile.changePage($('#idofpageyouwantogoto'), 'fade');
  });
});
相关问题