Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
192
rated 0 times [  199] [ 7]  / answers: 1 / hits: 20353  / 11 Years ago, fri, november 15, 2013, 12:00:00

I am trying to redirect to a different URL after a html video has ended. This cannot be using a FLASH player as it won't work on iOS devices. Any help or direction will be appreciated. Here is my code:






<head>
<script type=text/javascript>
myVid = document.getElementById(video1);
function redirect()
{
if (myVid.ended == true) {
window.location = http://www.google.com;
}
</script>
</head>
<body>
<video id=video1 controls=controls>
<source src=video.mp4 type=video/mp4>
Your browser does not support HTML5 video.
</video>
</body>



More From » html

 Answers
20

set the id of your video to 'myvid' and here is the solution



video = document.getElementById('myvid');
video.addEventListener('ended',function() {alert('video is ended');
window.location.href = 'http://www.google.com';})


here is the demo


[#74260] Thursday, November 14, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
benitoh

Total Points: 150
Total Questions: 113
Total Answers: 104

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
benitoh questions
Sun, Mar 21, 21, 00:00, 3 Years ago
Mon, May 13, 19, 00:00, 5 Years ago
;