<!DOCTYPE html>
<html>
<body>
<video id="myVideo" width="640" height="360" controls>
<source src="/i/video/shanghai.mp4" type="video/mp4">
<source src="/i/video/shanghai.ogg" type="video/ogg">
您的浏览器不支持 video 标签。
</video><br>
<button onclick="getCurTime()" type="button">获取当前时间位置</button>
<button onclick="setCurTime()" type="button">将时间位置设置为 3 秒</button>
<script>
var x = document.getElementById("myVideo");
function getCurTime() {
alert(x.currentTime);
}
function setCurTime() {
x.currentTime = 3;
}
</script>
</body>
</html>