Javascript 完成html格式的视频后转到其他页面

Javascript 完成html格式的视频后转到其他页面,javascript,html,Javascript,Html,我有这一页: <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src="miscript.js"></script> </head> <body> <div align=

我有这一页:

    <!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="miscript.js"></script>
</head>
<body>
<div align="center">
        <video id="myvideo" autoplay>
           <source src="008.mp4" type="video/mp4">
            Your browser does not support html5 videos
        </video>
</div>      
</body>
</html>
有什么想法吗

$("#myvideo").bind("ended", function() {
   //code to run when video ended
   //redirect to http://stackoverflow.com
   window.location.replace("http://stackoverflow.com");
});
没有jQuery:

var videoObj = document.getElementById('myvideo');

videoObj.onended = function(e) {
  //code to run when video ended
  //redirect to http://stackoverflow.com
  window.location.replace("http://stackoverflow.com");
};
通过使用匿名函数添加事件侦听器:

document.getElementById('myvideo').addEventListener('ended', function(e) {

    //code to run when video ended
    //redirect to http://stackoverflow.com
   window.location.replace("http://stackoverflow.com");
})
页面重定向:

  window.location.replace("http://stackoverflow.com");

注意:在加载DOM后尝试运行此代码

 $(document).ready(function() { //Run from here });
jQuery:

$("#myvideo").bind("ended", function() {
   //code to run when video ended
   //redirect to http://stackoverflow.com
   window.location.replace("http://stackoverflow.com");
});
没有jQuery:

var videoObj = document.getElementById('myvideo');

videoObj.onended = function(e) {
  //code to run when video ended
  //redirect to http://stackoverflow.com
  window.location.replace("http://stackoverflow.com");
};
通过使用匿名函数添加事件侦听器:

document.getElementById('myvideo').addEventListener('ended', function(e) {

    //code to run when video ended
    //redirect to http://stackoverflow.com
   window.location.replace("http://stackoverflow.com");
})
页面重定向:

  window.location.replace("http://stackoverflow.com");

注意:在加载DOM后尝试运行此代码

 $(document).ready(function() { //Run from here });
var vid=document.getElementById(“myvideo”);
vid.onended=函数(){
window.location.href=”http://test.html/";
};

您的浏览器不支持html5视频
var vid=document.getElementById(“myvideo”);
vid.onended=函数(){
window.location.href=”http://test.html/";
};

您的浏览器不支持html5视频

您是否尝试过将js代码放在html代码之后?是否尝试过将js代码放在html代码之后?