我想让这个视频自动播放,一旦视频播放完毕,我想让它重定向到另一个页面,完全自动化。没有点击或任何东西。我该怎么做?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>eve_</title>
<link rel="icon" rel="preload" href="images/evecircle.png" />
<style>
#video {
margin-left:-10px;
margin-top:-10px;
}
</style>
</head>
<body>
<script src="text/javascript">
function playVideo(){
var video = document.getElementById('video');
video.play();
video.addEventListener('ended',function(){
location.replace('https://stackoverflow.com/questions/49582133/no-idea-where-to-put-settimeout/49582203?noredirect=1#comment86172507_49582203'),
});
}
</script>
<video controls id="video" width="1300px" height="auto" preload="auto" autoplay="autoplay">
<source src="images/shorteve.mp4" type="video/mp4"/>
</video>
</body>
</html>
答案 0 :(得分:1)
您应该能够添加food.bill.dao.FoodDaoImpl
,然后在触发时调用您的函数。
eventListener
&#13;
答案 1 :(得分:0)
确保在加载HTML后(addEventListener
内部事件)调用DOMContentLoaded
。
在document.getElementById('video')
事件之外调用DOMContentLoaded
时,大多会返回null
。
初始HTML文档具有
DOMContentLoaded
事件 已完全加载并解析
document.addEventListener('DOMContentLoaded', function() {
console.log("DOM fully loaded and parsed");
var video = document.getElementById('video');
video.addEventListener('ended', function() {
console.log("The video has ended");
alert("The video has ended");
//location.replace('https://stackoverflow.com/questions/49582133/no-idea-where-to-put-settimeout/49582203?noredirect=1#comment86172507_49582203');
});
});
&#13;
<video controls id="video" width="200px" height="auto" preload="auto" autoplay="autoplay">
<source src="https://www.w3schools.com/tags/movie.ogg" type="video/mp4" />
</video>
&#13;