Skip to content Skip to sidebar Skip to footer

How Can I Redirect To A Url After A Html Video Has Ended?

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 apprecia

Solution 1:

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

Solution 2:

use window.location.replace('http://www.google.com'); so user dosnt get stuck in back button loops

<script>var video1 = document.getElementsByTagName('video1')[0];

    video1.onended = function(e) {
        window.location.replace('http://www.google.com');
    }
</script>

Solution 3:

Javascript:

document.getElementById('video-id').addEventListener('ended',function(){
     window.location.href = 'http://www.your-url.com';
 },false);

jQuery:

  $("#video-id").on("ended", function() {
       window.location.href = 'http://www.your-url.com';
    });

Youtube:

How to detect when a youtube video finishes playing?

Post a Comment for "How Can I Redirect To A Url After A Html Video Has Ended?"