gpt4 book ai didi

javascript - 视频结束后更改位置

转载 作者:行者123 更新时间:2023-12-03 02:10:36 26 4
gpt4 key购买 nike

我希望该视频自动播放,一旦视频播放完毕,我希望将其重定向到另一个页面,完全自动。无需点击或任何其他操作。我该怎么做?

<!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>

最佳答案

您应该能够添加一个eventListener,然后在触发时调用您的函数。

<script type = 'text/javascript' >
var video = document.getElementById('video');
video.play();
video.addEventListener('ended', onVideoFinished, false);

function onVideoFinished() {
window.location.replace('...');
} </script>

关于javascript - 视频结束后更改位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49589227/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com